#help-development
1 messages · Page 155 of 1
they should remake that on spigot forums
as long an api doesnt change
well ofc you can just check all known interfaces of event
good luck reading that block of text tho
and then just CTRL + F and search for Event
event.Event maybe, but some keyword that gets u down there
wtf
bleh
what was that meant to look like
original image
it has
just not in maps
i can spawn you a dust particle in every color of the rainbow
imma try this image, looks more promising
would be useful to have a png version of it grr
but then it won't have every color because it's already compressed
ah
just dont use maps
entityspawnevent?
I mean
it does give it quite a style
- it would probably make the already shitty performance of maps worse
if they added full rgb
cough 3d markers cough 2b2t cough
maps are decent enough
theyre not
I mean
i mean
Today on the oldest anarchy server in Minecraft, we uncover how 3D Minecraft maps DESTROYED 2b2t, and became the most powerful exploit in the server's history!
Get Honey for FREE today - https://joinhoney.com/fitmc
Honey finds coupons with one click. Thanks to Honey for sponsoring!
My Twitter: FitMC
My Instagram: fitmcsippycup
Music: AoC (War C...
the way bukkit did it is weird
and yes its as bad as it looks
3d markers do make sense tho
2d2t is just exploiting everything thats not a good place to judge mechanics
how can i compare 2 item's enchants
the way minecraft does it is weird
Maps are a very old concept, so it made sense at the time
As with a lot of things in Bukkit
It made sense at the time
needs to be revamped a bit
or at least like
drawImage method that writes directly to the buffer
setPixel is hella slow
PRs are welcome
Yeah but PRs are also terrifying
I'd rather not touch spigot code directly
if the code actually becomes good then it's no longer quirky and fun to use
lol that's an interesting perspective, sure
would be a statement, to say you've contributed to spigot
while u make pr add proper enchanting api plz
Yeah but like, how? That really doesn't explain much at all
thats a lot of custom stuff tho
@Since Tags 
i dont enjoy handling everything myself
Anvil? enchantments A + enchantments B.
Grindstone? clear enchantments
Table? Maybe a method to enchant an item would be neat. Make a JIRA ticket pls
Loot? idk what you mean
Villagers? I also dk what you mean
Librarians being abhle to sell custom enchants etc
I'd take kacpers API suggestions with a grain of salt xD
villagers - enchant as a trade
loot - in structure chests
thats do-able
what do you mean "enchant" as a trade
Yeah I have no clue what you mean
librarians sell them
EnchantmentStorageMeta
there is API for that lol
it is
whats the method for it
so im confused w that part
EnchantmentStorageMeta
Hi! I want to assign the variable staminaValue a value, that you get from somewhere
It's an ItemMeta type
this is why you take kacpers suggestion with a grain of salt
man is a legacy text format enjoyer
send that on
nothing good comes from that 😭
?paste
because legacy is better for most needs
at least faster to do
Only reasonable API suggestion thus far from the ones you listed is API to apply enchantments to an item at a specific level
Could throw that into ItemFactory probably
Maybe ItemMeta
Yh tbh that sounds like a good suggestion
i send
its easier to read on ?paste
that would need the entire enchantment table logic tho
Wait what im confused now
i.e. when you enchant an item at, say, level 30 at an enchantment table
Just a method to do that without the need for a table
cant u do it easier in datapacks tho?
didnt they mean like adding enchants to enchanting table lootable(?)
Oh, well adding enchantments is a whole other issue
We can't even reasonably support that in Bukkit. Bukkit is vanilla-centric. I don't think datapacks can do that either
You can add an enchantment to the registry if you want, but the client has no clue what that enchantment is
this is two times the same isnt it? my brain is dying rn
So in that regard it's not Bukkit's responsibility to add API for it
paper already has a method for enchanting with a level
I knew I saw that logic somewhere
yes yes it is
I avoid looking at Paper because I don't want my commits to be influenced at all ¯_(ツ)_/¯
no paper api
If someone wants to make a JIRA issue for a method to enchant an item, go for it. Someone will get around to it in the near future I'm sure. I've been on a PR tear personally
(no mention of Paper in the JIRA issue if you do make one though. Again, as little influence as possible)
oh btw thanks for ItemMeta#getAsString
i dont have time to annotate every class with deprecation suppression
recently stumbled onto it
You're welcome
whats jira short for
ItemFactory#createItemStack(String) was a personal favourite
Or whatever I called that method
and do you have a solution to my problem or not yet?
- No
- Cant
i dont even know who you are
just disable that in the ide settings
i prefer to have my plugins on spigot
I need to get around to doing @Since 
I don't think it's an acronym
rip @since
WHAT IS @SINCE
@since 1.18
The best thing ever
for example
It's a Javadoc tag that indicates when a method was added
ohh
They want to since all methods for their MC version
thats amazing
Which I don't think will get merged
omg
uh can someone explain why zackens reply is higlhighted and chocos isnt
save the value to config and read from config when you need it, also use more than 1 class
I didn't ping in mine
but its perfection put into textr
mine also isnt
or it is
Don't think it will get merged but if it does 
i dont see it, circle is supossed to be red
also no arrow, so i dont know where to look
it's just that the problem here is that this parameter is responsible for stamina and it changes with every step of the player
what are you needing the stamina value for
it would be perfection
for Stamina Plugin
oh is that for Stamina: X/10?
yes
run a scheduler on enable that runs every like 30 seconds that just gets their stamina value and send it to where-ever you need it
seems unnessasary
probably is
Do you really need to have player's stamina saved after a server restart?
maybe stor ethe max stamina
if thats dynamic
no clue why you would even need the stamina value to use anywhere
I'm new to coding so can you explain me in more detail or drop the docs
(scheduler i can do)
?scheduling
and then what is it?
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> Bukkit.getOnlinePlayers().forEach((player) -> ((PlayerStamina)Objects.requireNonNull(this.stamina.get(player.getUniqueId()))).update()), 20L, 1L);
}```
create a variable that you set inside the scheduler that you can get else where
also that timing is wron
wrong
the end should be 20l * 30l
for it to run everyone 30 seconds
the L at the end isn't needed
i forgot but does compiler do float cast internally?
context?
I have HashMap stamina and she inside in this part of the code you can see this.stamina.get()
does the compiler do (long)20 internally when putting 20 instead of 20l where a long is expected
why would it use float there... If anything it'd be long cast
it attempts to cast to whatever you start with
Either way it's a good question whether
BIPUSH 20
I2L
or
LDC 20L
is used, but once JIT kicks in it wont play a role
ah i meant to say long
my brains are fucked up by reading programming book for college
public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=1, args_size=1
0: ldc2_w #7 // long 20l
3: invokestatic #9 // Method requiresLong:(J)V
6: ldc2_w #15 // long 50l
9: invokestatic #9 // Method requiresLong:(J)V
12: return
LineNumberTable:
line 6: 0
line 7: 6
line 8: 12
uses latter approach
OK so I have this
new PacketPlayOutBlockBreakAnimation(9999, new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), stage);
the first argument is what im assuming the ID does it matter?
The entity ID does not need to correspond to an actual entity on the client. It is valid to use a randomly generated number.
I see, does it have to be consistent?
Also can I ask how you got that information just so if I need to use that in the future?
Assuming its Set Block Destroy Stage, most likely not
https://wiki.vg/Protocol is your friend
Any good anti bot plugins? ( i want the best one there is ) ( 1.19.2)
But its not destroy it could be any of the stages
Do beware that you need to search what the packet does, not what the packet name is
Because wiki.vg uses their own dumbed-down mappings
ideally you do 1 id / block
sorry its just my first time trying packets and my brain is just dead
you can reuse the number but it will override the previous value
hmm
What should the packet do?
Uh change the blocks damage
like the break animation
I tried player#sendBlockDamage but since the id is the same as the players
Set Block Destroy Stage
0–9 are the displayable destroy stages and each other number means that there is no animation on this coordinate.
Block break animations can still be applied on air; the animation will remain visible although there is no block being broken. However, if this is applied to a transparent block, odd graphical effects may happen, including water losing its transparency. (An effect similar to this can be seen in normal gameplay when breaking ice blocks)
Then it is what you want
if(if){
Return return = new Return(if);
return return;
}```
So just to clear the ID thing up. If I have it as a set number only 1 block could have the damage at a time because when another one triggers it will clear the old one
But if I have an id for each player only a single block could have that
which would be what I want
or should I go w block specific like imillusion said and just clear it up later w another packet
I do not know if you can use the same ID to break multiple blocks
yeah I wouldnt be able to cuz the latest one would override the old ones
you cant. it overrides the previous
I think going w what you said would be the most diverse so later on i could add items that can break multiple blocks at a time
I'd just need to send an update packet w stage 0 at the end right?
Wdym by 1 id / block
if you want to crack multiple blocks, just do like
hashCode(blockLocation) as the id
and reuse that hashcode for switching stages
I dont need to save it do I?
pretty sure that the block break "times out" after about 5 seconds
the implementation seems to be consistent wit hte blocks position so if I just use the same position it should be the same
Okok I got it I think
where can i download protocol lib 1.19.2?
What java runtime version do I need to compile my code so it can work for 1.16 and above
Omg it worksss!!!
Can be anything
Just not anything too recent (i.e. J16 is the latest I'd go)
Can someone pls tell me the sound and pitch so it sounds like a ship crashing into an iceberg
or like imagine the stone is coming out of the ground
and if someone knows if there is a website where i can test minecraft sounds that would help me a lot
tip
do a command
and either make it /testsound sound volume pitch
or make it /testsound sound and then loop through possible volumes and pitches
the second could help you get through them really quickly
set the volume/pitch step high and once you found a sound that gets close make it smaller
8-16 iirc, any of those between (inclusive) should work
heya. is the armor bar calculated client side or can it be handled by the server without packet magic?
yes and no
in that order
the bar shows the protection the server tells the client to show
you need to pretend its different if u want to change it
but im about 90% sure u need packets
gotcha
where can i download protocol lib 1.19.2?
I want to create a chain of TNT explosion in the direction the player is looking. About 10 blocks from the player
how can I do that? I want to spawn TNT every 2 blocks
get the location of the player
vector math with Player#getLocation().getDirection() and SpawnEntity
that location has a vector thats his sight direction
yea that
normalize that vector and save it, then clone it and call multiply (2) on it
on the location object u get from the player, call location.add(normalVector.multiply(10)), then do a loop for as many tnt as you want
no need to normalize as its a unit vector
the reason this works is because if you call location.add it modifies ITSELF, and returns itself afterwards
as a caveat, you need to call clone() to not mess up locations or vectors
I dont think I can make a player break a block w particles so um, how wouyld i spawn block particles? preferably without hardcoding every material
or well I could make it a config option ig
Yeah but how would I spawn it naturally like the block was broken by a player
spawn the correct particle where the block is and give its value the block material?
some particles have internal value for that stuff
color particles have color fields
the block particle has a block field
*material
btw I hope that this is like 5 lines that just draw poly
ah what i meant is that i modified the code so that it can spawn in circle segments
?paste
can I set a cooldown like there is for enderpearls for any item or no?
yes but im not sure if u can make it visual
i want it visual
i know how to make a cooldown system using hashmaps but i want this white thing over my item
Btw not really plugin related but is there anyway to add ping in a local server
material.setCooldown or smth iirc
Need it for testing purposes
gonna need to be more specific than that
Like
Increase ping
Delay between client and server
since its running on my computer its 0ms
but I need to see how it runs in like 200ms
anyhere knows the right command (and class) to get the current loottable from a chest?
When i cast my BlockData to a chest, all i get is NULL on chest.getLootTable();
Tested this on multiple chests in towns...
Any suggestions?
connect via a proxy
Could you explain? There is loot in the chests already.
What im trying to get, is a the current loottable of chests (non player placed ones)
yea i realized that a moment later
might be worth to just look for lootable in ?jd-s
but if you say youre getting null maybe ur using the wrong interface
havent worked with it yet
Also tried to cast my chest to Lootable, which is shown as obsolete event. But same result
Block is giving from the event. (which is show in my debug as CHEST)
Chest chest = (Chest)block.getState();
chest.getLootTable() == NULL
which event?
PlayerInteractEvent
thats... weird. it should show lootable. did you open the chest before already? I'm not sure but i think that if the chest was opened it removes the loot table since it had generated
Oh! that could be the case, does it not stay on the blockdata?
dont think so
maybe try using left click as key if you said yes since that doesnt open the chest
so you hit the left click quickly and wont destroy it
Will try, gimme 5min
remember to use a new chest
Aye
u probably forgot to add the repo
imports in maven are two things
a dependency and a repo
@smoky oak
if (event.getAction() == Action.LEFT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST){
Block block = event.getClickedBlock();
Chest chest = (Chest)block.getState();
Player player = event.getPlayer();
if(chest.getLootTable() == null) {
player.sendMessage("getLootTable NULL");
} else {
player.sendMessage("LootTable:"+ chest.getLootTable().toString());
}
}
that did show the loottable
so it was the chest being opened
aye, after closing again, its gone.
preference mainly
idk i only ever used maven
though some stuff is only available for maven respectively gradle
It looks deprecated.
There's only two constructors for NamespacedKey It looks like you are using the one with two strings as its parameters?
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
}
}, 0, 0);
what does two of these last arguments mean?
trying to call method every x second
ide says l and l1
Is there a way to make actual custom enchants or do I have to do add a lore and get the lore and change what happens upon that
You can use the Enchantment class provided by spigot and it will tie into the Enchanting table, but it's not that well documented.
I'm not talking about enchantment table. I have been making a custom economy plugin and starting on the shop. I want to add custom enchantment books which you can use on tools with anvils
that sad
well thanks
Do you think it would be easier to just make a drag and drop method?
Like you drag the book over an item and apply it
Im whitelisted (in whitelist.json), but i cant join server. Should i reload whitelist? Looks like getServer().reloadWhitelist(); is not enough
Also whitelist.json doesnt have name :
[
{
"uuid": "my-super-uuid-real-more-numbers"
}
]
I'd guess that you already answered it yourself
It could be because of the missing name
how do I check if Vector's are similar?
.equals()
hello! I'm stuck in my code. I don't understand how to put text on the sign
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player) sender;
Location web = p.getLocation();
int weby = (int) (web.getY() + 100 );
Location web2 = new Location(web.getWorld(), web.getX(), weby, web.getZ());
PacketContainer openSign = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR);
this.position = new BlockPosition((int) web2.getX(), (int) web2.getY(), (int) web2.getZ());
p.sendBlockChange(this.position.toLocation(web2.getWorld()),Material.OAK_WALL_SIGN.createBlockData());
openSign.getBlockPositionModifier().write(0, this.position);
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(p, openSign);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return true;
}
}
which event is called when the item fully burns?
@ anyone using IntelliJ, there's a plugin for spigot/forge stuff
lets you preview chatcolors at least, it's handy
I'm not sure what else it does yet, but the most recent version of IntelliJ straight up recommended it, so I guess Jetbrains knows people use it for Spigot lmao
intelligent
Minecraft developement plug-in
ye
I haven't done much else with it LOL
mostly because I legitimately have no idea what it's capable of
you can create spigot plugins and such with it
it’s just a small utility
@everyone|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| _ _ _ _ _ _ @torn oyster
lol
i find that thing funny
Whast the datasource class name for the postgresql driver?
sir this is help development
is there built in api for getting server tps ?
StringBuilder sb = new StringBuilder( ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " );
for ( double tps : MinecraftServer.getServer().recentTps )
{
sb.append( format( tps ) );
sb.append( ", " );
}
sender.sendMessage( sb.substring( 0, sb.length() - 2 ) );```
found that code in tps command too, looks like i have to run buildtools --remapped to gain access to MinecraftServer ?
It is nms yes
ty
You could manually track it as well, tbh
I asked if there is built in api 🙂
yeah there's not a super accessible one
but since the NMS to get it isn't obfuscated, you could just reflectively grab the TPS via NMS
I think I did that, actually
but apparently I removed the code to do it
I've already done this way
big bruh
I have no idea if there's a way to get the NMS version string easily nowadays, but the way I did it - which still works - was uh
public static final String NMS_DOMAIN = "net.minecraft.server";
public static final String CRAFTBUKKIT_DOMAIN = "org.bukkit.craftbukkit";
public static final String CRAFTBUKKIT = "craftbukkit.";
private static String version;
private static String nmsPackage;
private static String craftbukkitPackage;
/*
* https://gist.github.com/ReflxctionDev/84a5753a69f426f48ffe75f7ab3adcbb
* pointed me in the right direction when it came to actually getting the version string.
*/
static {
version = Bukkit.getServer().getClass().getName();
version = version.substring(version.indexOf(CRAFTBUKKIT)
+ CRAFTBUKKIT.length());
version = version.substring(0, version.indexOf("."));
nmsPackage = NMS_DOMAIN + "." + version;
craftbukkitPackage = CRAFTBUKKIT_DOMAIN + "." + version;
EmberCore.log(Level.INFO, "You're running NMS version " + version + ".");
EmberCore.log(Level.INFO, " NMS package: " + nmsPackage);
EmberCore.log(Level.INFO, " CB package: " + craftbukkitPackage);
}```
it's a bit ugly and verbose but it works just fine
ignore the logs, not necessary
oh, ew, it's string concat. get out of here
literally so old i'm not even using my new log methods
then to get the class, I just wrote a helper method
public static Class<?> getNMSClass(String className) throws NullPointerException {
String fullName = String.format("%s.%s", nmsPackage, className);
try {
Class<?> clz = Class.forName(fullName);
return clz;
} catch (Exception e) {
// generally speaking catching Exception is bad but for the sake of example
// just do whatever here
}
return null;
}```
after that you can just reflectively invoke getServer() and fetch "recentTps" from that object
should be version independent unless something changes in the packaging/classes, but that's on Mojang for randomly changing things
String internalVersion = Bukkit.getServer().getPackage().getName().split("\\.")[3];
That will get you the CraftBukkit revision
I feel like that wasn't there before LOL
hmm
no it was
it's just java reflection
weird. i probs got this code somewhere and never bothered to improve it, but that's a lot cleaner
one note
Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
need the getClass
Yeah
quick test and that worked just fine
why does sendPacket(((CraftPlayer) owner).getHandle(), new ClientboundRemoveEntitiesPacket(npc.getId())); sometimes not remove an NPC?
Is there a way to not translate the last part of this config.yml message
Color-Code-Info: "&fFeel free to use &acolor codes (&0-9, &a-f, &k-o, &r)&f." ?
I mean (&0-9, &a-f, &k-o, &r), so that it's not translated into colored chat
Nevermind, I think the easier solution might be to just rewrite it like this
Color-Code-Info: "&fFeel free to use &acolor codes (&[0-9], &[a-f], &[k-o], &[r])&f."
You could also just not translate alternate color codes on that message.
I'm not doing that actually, I'm sending the message as is
has anyone ever made a music library?
that reads from a midi or something and converts it into a Song class or smth that they can just do Song#play(Player)
and it uses minecraft sounds
I mean that information has to be sent to players using a resource pack
But you can do that already with vanilla. Player#playSound() accepts a string
hey I am just failing to unload worlds via Bukkit.unloadWorld(string, false);
also with the world object
If you want to do it just with noteblocks, there are tons of API for those too
I don't really know what to look at for this one
ideas?
how can this even return false?
This through a plugin?
That shouldn't parse normally
idk, somehow it does
Does anyone have an idea how I could approach this:
I want to replace every empty line in an item meta's lore with - symbols. They should be as many as are needed to make the line containing them as long as the longest line in the lore (or display name if it's longer than the lore)
My first idea was to just iterate over the lore and see how many characters the longest line contains, but then I realized that some characters have a different width than the - symbol. That's where I'm stuck rn
I am very lost about this one
it is literally impossible to measure the screen space of text in minecraft
resource packs change fonts and font sizes, different languages have differently sized and spaced characters
and each character occupies a unique amount of space, it's not monospaced
doesnt java have something like text = text.replace(" ", "-");
but that would replace the spaces between the words so maybe replace 2 spaces in a row with 2 minuses replace(" ", "--");
I think even doing that would not result in an accurate amount of - symbols due to the reasons Magma pointed out
ok
Think I would have to know the player's font and get the width of every single character, add them up and divide that by that font's - character's width or smth
but don't think that it's possible to get a player's font?
You could use the DefaultFontInfo class from the CenteredChat resource that's been on the forums for a while and use that to get the length of the longest lore line. Then use that to make your line separator string.
Did you register your command? Also, what are you typing and where?
Also, the check for if sender is null is redundant since CommandSender is annotated as @NotNull
Probably ur args are wrong
the way you're using them, your command would have to look something like /command <idk> ver <player>
and this is impossible with args length == 1
as you're running this on an else after a if(args.length != 1)
so ver is args[0], player is args[1] and x is args[2]
args.length == 3
probably wanna use if(args.length > 3) instead of != 1
then check if args.length is 1 and args[0] equals "ver"
That would only work for people using no texture pack / texture pack with default font I guess?
Yea, it's just a start, but if it's possible to get the font they are using, you could refactor and make it resolve the letter width.
I hope it's somehow possible to get their resource pack's font, I'll see if I can find something, thanks
Commands look like this:
/command args[0] args[1] args[2] args[3]... etc
So if you want your command to be
/command ver <player> <x> your player is args[1]
You’re checking player args 1 at args length 3
And yoi can do it in one if, check if args less than the args you’re looking for if it is send message else, return command etc
Java counts from 0, your args don’t match up, unless im tripping im still learning too
No
Arg0 is 0
0, 1, 2, 3 etc
Ignore base command
And you can do all them checks in one statement
And send just one usage message, then else <your code>
No problem
how would i spawn an entity (a dropped item) and then make it ride an arrow?
class ChorusArrow : org.bukkit.event.Listener {
@EventHandler
private fun shootEvent(e: EntityShootBowEvent) {
val arrow = e.consumable
val projectile = e.projectile
if (arrow!!.isSimilar(ItemsManager().chorusArrow.item)) {
projectile.world.spawnEntity(projectile.location, EntityType.DROPPED_ITEM)
projectile.passengers.add(???)
//this is not important
projectile.persistentDataContainer.set(NamespacedKey(Fletching.plugin!!, "id"), PersistentDataType.STRING, "chorusArrow")
}
}
}
``` btw this is kotlin sorry
create a variable and set it to the spawned entity?
how would i target the spawned entity?
What do you mean with "target" ?
Entity item = spawnEntity
passengers.add(item)
Ty!
How do I differentiate between the player clicking another and the player being clicked with EntityInteractEvent?
Theres a playerinteractevent if that helps
is this the correct way to write and read UUIDs over a network connection?
cant really test rn
Thats just removes the need to check for an instance of player, I'm still not sure how to differentiate being clicked from clicking
pretty sure that's the order, yes
I dont think being clicked triggers an Interactevent
PlayerInteractEntityEvent
getClicked, getPlayer
That appearently only goes for right clicks, not sure if thats whats wanted here
Any plugin recommendation for Spigot 1.19 for backpack cosmetics
EntityDamageEvent
Not even sure if youre just guessing at this point. The Playerinteractevent has the clicking player, which means you can (with a bit of logic) get the player that was clicked
should i create a tabcomplete class for all commands or one for every command?
and how to register tabcompletions in the Main.java?
i have a class for each command that houses the command logic and the tabcomplete logic
perfect, thy ❤️ register with getCommand('commandname').tabComplete() or anything like this i think?
you can register it almost the same way you register the command, #setTabCompleter
but yes
okee thx 🙂
so intelliJ says i should move it to a separat class, but it whould work like this, right?
package com.schwerthecht.poster.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.List;
public class CreatePoster implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command cmd, String label, String[] args) {
// check if Player
if (!(commandSender instanceof Player)) { return false; }
//TODO: create new poster
//TODO: place poster
//TODO: register poster
return true;
}
}
public class CreatePosterTabComplete implements TabCompleter {
@Override
public List<String> onTabComplete(CommandSender commandSender, Command cmd, String label, String[] args) {
return null;
}
}
you can just make the same class implement Tabcompleter
💀uh no
wdym no
okee? so it doesn't matters right?
yet you're not annotating them when overriding
which breaks the implicit contract
yeah it no matter
Why not use TabExecutor? Or am i misunderstanding?
\
how do i sample a cartesian function inside a specific range, such that i can give a delta value for the distance along the graph to be sampled, assuming two-dimensionality and a maximum distance from the origin?
also, is it possible to do as such with functions that give more than one value for x?
You first need to define a method which represents the function.
For example f := x -> x ^ x (or in school math terms) f(x) = x ^ x
would need
public double func(double x) {
return x * x;
}
heyy im looking for OP Minecraft Developer for good money
if i have to hard code its kinda missing the point
This is still possible
For this purpuse you can use crunch
You'll need to filter your parsed function in another function to "crop" your graph
heyy im looking for OP Minecraft Developer for good money
huh
someone wanna strat work?
Wrong channel, ask in the spigot forum
in Google?
uh @lost matrix can i even use that to make a evaluation over graph distance?
What i meant is that i want to essentially give a function and plot along that function every distance x, but i dont see how i could do that with crunch without using a ridiculous amount of sampling
dm me if you want to give me a try
Process are the same. Parse the function with crunch, and act as if you had a method
how to prevent double clicking on interactevent
this code exactly
public void onPlayerInteract(PlayerInteractEvent event){
if(event.getHand()== EquipmentSlot.OFF_HAND) return;
if(event.getAction()!= Action.RIGHT_CLICK_AIR && event.getAction()!=Action.RIGHT_CLICK_BLOCK) return;
i mean when player interacts and toggles pressing it it triggers over and over
keep a counter then
wdym
ur saying u want a player to only toggle it once even if they interact multiple times
so just keep a counter if they had activated it
Create a static set and save player to it-> New runnable to remove it after a few tick
Static :c
I completely dont use statics
Static has it's use
You just need to know when to use it
This is not one of the cases where it should be used
except for constants
private static final
this is my main method
public non-static void main(String[] args) {
}```
u should use static for two things
methods that dont change the class theyre part of and variables that should only exist once
Yes you can
yall aint helpful
the only idea i have is to get the derivative & check that but that wont work with all graphs
bugged
?paste
https://paste.md-5.net/akenuyatoc.java I dont think there is a way to handle line 29
snake
show me
.
this code is cring
if it works
Your runnable will never end as you set the remained inside the run method
also chaning itemMeta every clickevent
why don't you do that in constructor
and why is it static lol private static Economy economy;
no need for that
why
I just told you why, Line 40
cuz you init remained variable with value 5 every run() method
and work with this local variable
not with global one
You got the other 3 runnables correct, but not the first one
want to see terrible scheduler code?
for(int i=0; i<displayTimes.get(1); i+=displayTimes.get(0)){
Bukkit.getScheduler().runTaskLater(Echo.getInstance(),e->{Particles.renderAllParticles(displayPoints,4,1,from,to);},i);
}
You also never initialize economy in that code so it will be null.
you are setting it every time a player has a cooldown
How can i prevent player to enter the event for multiple times. Because when they got interaction and toggle pressing it multiply entering the event
which is every single interact event
... a static set ?
this is always going to be true playerWhoHasCooldown.add(p); if(playerWhoHasCooldown.contains(p)) {
You havent realize your problem here ?
If (hashmap not contain p) add to map
If it always add to map your statement always true
It is ALWAYS going to contain it as you just added it.
noob level 99
bro then player will be able to click again
yes, your cooldown does nothing
what are you even trying to do
just make a simple manager
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class CooldownManager {
private final Map<UUID, Integer> cooldowns = new HashMap<>();
public static final int DEFAULT_COOLDOWN = 15;
public void setCooldown(UUID player, int time) {
if (time < 1) {
cooldowns.remove(player);
} else {
cooldowns.put(player, time);
}
}
public int getCooldown(UUID player) {
return cooldowns.getOrDefault(player ,0);
}
public void removeCooldown(UUID player) {
if (cooldowns.contains(player)) {
cooldowns.remove(player);
else {
//not in cooldown
}
every single time the interact event fires you add the player to your cooldown. then you ask if they are there and run the rest of your code.
Calm down
As both NukerFall and ElgarL has said plenty of times now you are doing it wrong
If you want help, and want to actually learn how to do it then you have to take the advice they / and others are giving you
otherwise, why are you coming here to show the code?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
russki?
yes
? U sure u use a static value ?
also at least make comments on english
bru
it's not understandable and i don't want to translate each message myself
?learn java
you want to learn java
google Denis Cyplenkov
no
Lo pex
who knows
мяс
Limpez if expext help you should make comments in english
that's what i just said lel
Lmao i hate the word corrector because its for Spanish and mix everything when I talk in english
If you actually want help I will help you, just take the advice I've sent
Agree
google Penis Rebenkov
Google cache when
I know but this is simple and understandable for him
if he does not know how to use maps
Hello, question is this how to get a EntityPlayer's Pitch?
:
private Location getLocation() {
return new Location(
npc.getWorld().getWorld(),
npc.locX(),
npc.locY(),
npc.locZ(),
npc.y,
npc.bp);
}```
Is it `bp` or something else
getPitch() ?
No
xRotO is remapped pitch
Oh alright thanks
https://paste.md-5.net/akugowifac.java Can you check please
line 31 is going to set teh cooldown to 5 every time a player interacts
Tell me what you want it to do, what the problem is and please translate the text to english
So its easier to understand
float location = player.getLocation().getPitch();
He was wanting NMS pitch
https://paste.md-5.net/asekobonar.java I want to do something when player right clicks with an item which has custom model data. But as the event requires it when player over and over clicks it. I want to prevent it
My bad, long day :|
Yep. he doesn;t understand what is CB and what is NMS
No problem :D
Well, I did send you a class which is simple to use and understandable. if you use the method setCooldown(player, time) it will remove and add the player to the map as you want it to
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class CooldownManager {
private final Map<UUID, Integer> cooldowns = new HashMap<>();
public static final int DEFAULT_COOLDOWN = 15;
public void setCooldown(UUID player, int time) {
if (time < 1) {
cooldowns.remove(player);
} else {
cooldowns.put(player, time);
}
}
public int getCooldown(UUID player) {
return cooldowns.getOrDefault(player ,0);
}
public void removeCooldown(UUID player) {
if (cooldowns.contains(player)) {
cooldowns.remove(player);
else {
//not in cooldown
}
it goes on uuid so if you have a Player variable you have to do player#getUniqueID
Ah yes thank you elgar, i forgot to add it inside the case
tysm for help ❤️
Yeah that can work
Thanks
You just tas'd yourself 😄
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
anyway to have an item that has an attack speed like vanilla items
wha-
getHeldItemSlot(int index);
w h a t
what event is triggered when the player changes their armor
yes, but it would be accurate to the time passed on the server
which is what you usually want
I think both ways are equally valid depending on what you wanna do
actually idk xD
you might have a point
my bad
i thought there was a reason but I blanked on it
well yes
I am more experienced with like item cooldowns or other times for gameplay elements
is it possible to send nbt text (text as in /tellraw) as plugin.yml usage text? and if yes, how to do?
thats just a java method..
Like for commands? No
Well kinda. Always return true in your onCommand and send the text yourself
Right, but they specifically mentioned the plugin.yml, which is not possible
No, but you can read the text from there
Does anyone know how to keep effect after death
check if they have an effect before dying and reapply
maybe
you should use a map for that I think
so listen to the PlayerDeathEvent, put in map and then listen to the PlayerRespawnEvent
check if the player is respawning inside the map and if they are delay it by a tick or two and give them back the potion effects you have stored
I think just listening to playerdeathevent will work
get the players effects
and apply them again a tick later
player#getActivePotionEffects() (remember to check if its not null) and use a Map<Player, Collection<PotionEffect>>
How can I stop a fire charge from lighting the floor on fire, but keep the explosive effect?
how would only playerdeathevent work
??xd
.
Hi
?nohello
isnt this #help-development ?
No?
lul
and it should be ItemsStack not int for that
I think he should read more about javadocs
Because javadocs will help you
My father have told me many times that he wont be al life together with me so i need to care my self
This apply for development
?tryandsee
are you trying to get an item in a specific slot?
how fix, Unsupported class file major version 61
java 17
plugin version is 1.19
so should work
It means Java 17 (major version 61) compiled the class file, and if we try to run the class file under Java 16 and below environment, and we will hit Unsupported class file major version 61.25 Aug 2022
so, how would i fix it?
are you using intellij for the building?
yes
check your sdk version
are you using java 17 as your jre
where do i find that?
im dumb / blind
oh nvm
1.8 works fine
but i wanna use var
because its easier
and some other things
i've tried to change my java version to 17 multiple times
even 16 and 18
help
yeah, whenever i compile it
whats the name of the packet where the player receives a message from the server?
check protocol docs
i did
but idk how to read them :(
theres one for 0x16 that looks like I could use
but beyond that im not sure
Main article: Plugin channels
Mods and plugins can use this to send their data. Minecraft itself uses several plugin channels. These internal channels are in the minecraft namespace.
More information on how it works on Dinnerbone's blog. More documentation about internal and popular registered channels are here.```
plugin channels are something different
you're looking for system messages
yeah
okay so whats the packet event's name
like play_server_server_difficulty refers to changing difficulty
what ab that one?
theres both
i have a feeling maven 3.8.1 uses java 16 still
if you can help me find what its called id appreciate it
get it, then add it then set it
i've tried to get help from many people
wait ill create a thread
when i had the issue i just swapped to gradle, it worked lol
System Chat Packets
one sec
Config#Set will override the value if it exists
one moment
double speedAdder = config.getDouble("stats.miningSpeed") + 100.0;
config.set("stats.miningSpeed", speedAdder);
so can anybody check out my thread and help?
it seems like such a simple problem im just way too bad at this stuff
is there a way to remove only 1 of an item
yup
hey how do i read a file in UTF-8 in Linux, when i use -Dfile.encoding=UTF-8 argument it works in Windows but not in Ubuntu
Thats resulting Unicodes not working
It should be the same flag
Make sure to save everything in UTF-8
oh and when changing format make sure to correct some of the characters
Can somebody please help me in #1024709638735794258
i really cant find anything ive been trying to find solution sfor a day now
I want to calculate force applied to Ship
I have ship and also direction of the wind
I tried every Physics Law but can't get it to work
Some poop illustration of what I want:
is that a b-boat?
So i have custom item, then i give that item to player and i change the lore of that item in hand. Is there any way to say if it is still that custom item?
like adding a tag that its a custom item
?pdc
cool thanks
The force of wind equals the air density times the area times the wind speed (velocity) squared. Write the formula as F=(unit area)(air density)(wind speed squared). The air density will change based on altitude and/or temperature. All units agree, whether metric, English or System International.
find cross section and wind speed
plug in number
Is ItemStack serializable?
ye
i think u can click on a class and open it and if it implements Serializable, its serializable
but not sure
I'm wondering if I can outputstream it to bytes and later on read it
you should convert it to an nsmitemstack before
Two possibilities: convert the serialized string into bytes, or serialize the item by yourself (may be better)
base64
@quaint mantle https://www.spigotmc.org/threads/encode-decode-player-inventory-with-armor-base64.400892/
Why base64?
I want to store them as bytes
Using a String has the issue that they have a limit (actually yes, there's a limit)
I had an issue before in which a database did truncate because of a long String 🤨
honestly if ur database breaks because a serialized item is too long the issue is the item not the database
Another plugin's item
Not my fault
thats a good point
actually he has a point, for example have a shulker filled with a hole bunch of nbt items...
this produces a really large string
in base64
the only thing that really has long nbt tags are books
I remember that Mojang did compress whenever saving stuff inside inventories, I know this because of a dupe exploit that required books
nah
that dupe was because chunks had a maximal storage size
if you give too much data into a chunk and unload it
it cant save
if you provide this plugin for players..
if you realize we got the same issue with databases 🤨
tiny blob, mediumblob, etc
depends
hi zorro
I mean most dbs allow you to configure these things afaik
I cannot let the database allocate 4GB just to solve the issue.
What if someone finds out how to stack shulkers inside shulkers and manages to upload 200 MB of an inventory? lol
I remember someone said "never trust the user, user is stupid"
anyway the good thing about databases is that you have relational ones
which allow you to structure the data
kinda ironic that postgresql has a json datatype lol
actually a CharSequence wrapper
ehh internally it's a char[] that implements CharSequence methods
a CharSequence implementation
Could someone help me with this? https://www.spigotmc.org/threads/making-a-block-trail-behind-arrow-but-need-sleep.574624/
Hi, you know how i can create a skull item in my menu with a base 64?
spawn it one block behind the arrow?
not on the same location
Yes
that's the solution
How can I do that, first time making a plugin
Can you explain me how to create a Spigot Plugin for 1.19.2 where I need to send a message to a player with a "clickable text"?
I've all the functions of my project, I'm using only Spigot Api 1.19.2 and I need to send a message with clickable text, Idk how to do that
and find a block which is behind the arrow
Soooo google?
TextComponent
where are the api?
I failed trig, still can do vector maths
you just gotta know how to think in 3d, and how polygons and lines work
and you should, in theory, be fine
i didn't
and i'm having problems sometimes
:0
?jd-bcc
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
think it's here somewhere
I'm asking much if I ask you a small example? Because is all the day that I'm serching how to do it and I haven't find something that works without craftbukkit
basically you run a task timer
when player shoots arrow
When arrow hits the ground you stop it
Inside the timer you do mafs part to get the block right behind the arrow
And if it's air replace it with a block type you need
help my gradle cache is consuming 10gb
this is for bungee plugin, I'm doing a spigot plugin
it's not
at least shouldn't be
net.md_5.bungee.api.ChatColor and others are included in spigot as far as i remember
at least chatColor
player.spigot().sendMessage(component);
yes
umm spigot is a fork from craftbukkit isn't it
basically includes everything from org.bukkit
and has own stuff
without spigot/paper you can't send clickable text as i can see
so it won't work on default CraftBukkit
Just out of curiosity would you send for example; player.sendMessage(message) as in the textcomponent variables name
After you’ve built the text component
Yeah
with TextComponent message = new TextComponent("Click me"); => The IDE says The constructor TextComponent(String) is not visible
maybe wrong import
dont use awt one
Just use ComponentBuilder it makes it prey easy
using spigot api I can't find a different import
