#help-development
1 messages · Page 1759 of 1
I'm trying to use as less plugins that possible... for now I'm using only HologramAPI
oh
well luckperms can help with setting up permissions to groups or as you call it “roles”
well if you want to use less plugins then idk how to sadly, sorry
You generally are going to want a permission plugin for most servers anyway
Depends on the entity
ArmorStand has setVisible
Other entities generally use a potion effect
what about an entity that you can ride on
You can ride on anything
well what i’m trying to do is to right click on a stair and then the player will sit on it but i only figured out on the right click detection but not the entity
I would use an armorstand
oh i never knew that
They can easily be made invisible, you can also set noGravity and they don't make sounds
No AI to tick either
oh
well now what i need to figure out is to summon it when it is clicked and then remove it when it is done sitting down
InteractEvent and DismountEvent
thanks
Creating descriptive parsing errors
does someone know a lifesteal smp plugin for 1.16.5?
Would anyone have an idea how to make custom roles that give permissions to player who have these roles?
P.S. I want to make these roles with my plugin (to code it) not with another plugin such as LuckyPerms
Why does this not work,
public void onInteract(PlayerInteractEvent event) {
if (!event.hasItem())
return;
if (event.getItem().getType() != Material.POTION)
return;
if (event.getClickedBlock() == null) {
event.getPlayer().sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "Use potion at a respawn tower!");
event.setCancelled(true);
return;
}
}```
when holding a potion and clicking the floor or any block it doesn't send the message
Nothing happens if I click the air either?
Is the event registered? Debug it
How do I debug something in java?
Never did it before
Print it in console?
Like the server's console?
How ever you want.
System.out
Bukkit.getLogger
JavaPlugin.getLogger
Bukkit.broadcastMessage
Etc...
Which one logs it into the server console?
All of them technically xD
Bukkit.broadcastMessage sends to chat as well though.
should I check use that to check if playerinteract event is being registered?
Yeap
kk
Well you would know if its registered actually. Did you write
Bukkit.getPluginManager().registerEvents
anywhere?
no?
Then you didn't register the listener lol
Is that an import or?
You put it in your onEnable or somewhere that the code is ran.
What do I put after .registerEvents is it registerEvents(PlayerInteractEvent)?
Depends on your listener and the code where your listener is.
It is in the main file
https://www.spigotmc.org/wiki/using-the-event-api/
I recommand reading that
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Thank you ❤️
target.teleport(404.5, 66, 92.5); is this not how you teleport a player?
It is
Hey so im trying to make a leaderboard of the top 10 players in my plugin, this is my current code but it displays all users not just top 10, how do I fix this? ```java
private static final HashMap<OfflinePlayer, Integer> unsortMap = new HashMap<>();
public static final boolean DESC = false;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player) sender;
p.sendMessage(ChatColor.GREEN + "----------");
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
unsortMap.put(player, TazPvP.statsManager.getLevel(player));
}
Map<OfflinePlayer, Integer> sortedMapDesc = sortByComparator(unsortMap, DESC);
printMap(sortedMapDesc, p);
return true;
}
private static Map<OfflinePlayer, Integer> sortByComparator(Map<OfflinePlayer, Integer> unsortMap, final boolean order)
{
List<Map.Entry<OfflinePlayer, Integer>> list = new LinkedList<>(unsortMap.entrySet());
// Sorting the list based on values
list.sort((o1, o2) -> {
if (order) {
return o1.getValue().compareTo(o2.getValue());
} else {
return o2.getValue().compareTo(o1.getValue());
}
});
// Maintaining insertion order with the help of LinkedList
Map<OfflinePlayer, Integer> sortedMap = new LinkedHashMap<>();
for (Map.Entry<OfflinePlayer, Integer> entry : list)
{
sortedMap.put(entry.getKey(), entry.getValue());
}
return sortedMap;
}
public static void printMap(Map<OfflinePlayer, Integer> map, Player p)
{
for (Map.Entry<OfflinePlayer, Integer> entry : map.entrySet())
{
p.sendMessage(entry.getKey().getName() + " " + entry.getValue());
}
}```
It says Cannot resolve method 'teleport(double, int, double)'
I have no idea how to do that
Could you show me an example please
Is it using .getLocation()
That's one way
Could you show me an example please
or wait
target.teleport(event.getPlayer().getLocation().set(404.5, 66, 92.5));
Is this right?
java
no
As I've told you before you should learn Java instead of asking people to spoon feed you
I didn't ask you to spoon feed me did I
I asked you if you could show me an example
I didn't ask for my specific code any example can help
Thank you very much
np
Location loc = new Location(target.getWorld(), 404.5, 66, 92.5, 0, 0);
target.teleport(loc);```
Is this correct?
👍
https://hastebin.de/ceropolija.properties anyone know what this is from?
anyone help?
code
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class ReloadNoInvis implements CommandExecutor {
private NoInvis noe;
public ReloadNoInvis(NoInvis noe) {
this.noe = noe;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.isOp()) {
noe.reloadConfig();
sender.sendMessage("Reloaded NoInvis.");
}
return false;
}
}
the main class is just registering the event how you would
command*
Simply return after printing 10 lines
oh thats way easy actually, just like amount++; if amount is >= 10 return;
post it too please
Pretty much yeah
Say, quick question about prepare enchantment events...
Does setEnchantmentLevel do anything?
example:
e.getOffers()[0].setEnchantment(Enchantment.KNOCKBACK);
e.getOffers()[0].setEnchantmentLevel(5);
e.getOffers()[0].setCost(60);
Both setEnchantment and setCost do work but setEnchantmentLevel does nothing except for changing the display name...
how do I get a player from a differnet listener, for example I have a death listener how do I get that player who died from another listener
Save player in a weak set
What is that?
how can i make EntityArmorStand movement using velocity?
entityArmorStand.getBukkitEntity().setVelocity(new Vector(0,1,0));
and i must send packets, yeah?
Java uses milliseconds right?
no
if you don't actually have the armor stand on the server
good luck simulating its velocity
How would i give armor to my custom mob
and how can I change that movement speed?
Does anyone idea why this gives me a cast error
Sign sign = (Sign) world.getBlockAt(X + x, 1, Z + z).getState();
sign.setLine(0, String.valueOf(temperature.a(x >> 2, 0, z >> 2)));
sign.setLine(1, String.valueOf(humidity.a(x >> 2, 0, z >> 2)));
sign.setLine(2, String.valueOf(altitude.a(x >> 2, 0, z >> 2)));
sign.setLine(3, String.valueOf(weirdness.a(x >> 2, 0, z >> 2)));
?
The stupid sign took me more time, than the biome nms xd
import org.bukkit.block.Sign;```
this is my import
Is the block a sign
hmm, it should, because I place it 1 row higher, but you have a good point, I am trying to check it rn
Very curious why a sign is being placed at bedrock level
isn't it 1 block above it? and I am trying to create custom biome grid based on the multi noise generator and I am just using it to hold the debug data as temperature, altitude, ....
How do I make a method to give a baby zombie armor
For each one I define
That could work for each one *
For some reason, uncommenting this line
Sign sign = (Sign) world.getBlockAt(X + x, 1, Z + z).getState();
freezes the chunk generation.
ik, that it's probably because I am getting it from the world, not the chunk, but is there some way, how to use only chunk and not world (because I didn't find a way how to get block state using the chunk object)
i don't have any idea, if I understood you correctly, but try using e.getMessage() instead of e.getFormat()
if I didn't understand you correctly, some example of the input and output can help
oh, ok
So if I need to check between multiple items when doing something is it possible to create a material list that I can check easily because right now my if conditions are really long using or for each material im checking
List<Material> matList = Arrays.asList(Material.STONE, Material.DIRT);
Ok sick thanks
Set<Material> matSet = EnumSet.of(Material.STONE, Material.DIRT);
@graceful oak
Whats the difference?
faster
Interesting alright thanks
how can I check who used the nickname Proscreeam1337 (for example) use API?
Question (Not spigot-specific, but helps to ask here):
How can I add multiple versions of a single project to my IDE, and allocate each version to a class?
I'm having some issues where some classes get a ton imports that have changed / got removed, and it'd be nice if I could just work with the code directly instead of doing a crazy reflections dance
and that's the problem
I haven't uuid now there is no player with this nickname
I can see on nameMC who used this nick before but on mojang API idk ;/
Language API
https://github.com/jaqobb/namemc-api Might help but idk
NameMC (https://namemc.com) Java wrapper. Contribute to jaqobb/namemc-api development by creating an account on GitHub.
Why if the EntityArmorStand is marker/is no gravity, velocity movement doesn't work?
How do I make it so the Ender Dragon is unable to break blocks.
@EventHandler
public void stopDragonDamage(EntityExplodeEvent event) // Listen for the event...
{
Entity e = event.getEntity();
if(e instanceof EntityComplexPart) // it it's a part of a dragon...
e = ((EntityComplexPart)e).getParent(); // ... get the dragon...
if(e instanceof EnderDragon) // if it's a dragon...
event.getBlocks().clear(); // ...clear the list of destroyed blocks. A event.setCancelled(true); should work, too, just have a look what you like more. ;)
}
So I'm working on an aspect of my plugin that will spawn an ender dragon above ground. What I want it to do though, is treat all blocks as if they were...
because all velocity is cancelled
or null
can I get around it somehow?
i mean you can set its gravity on and cancel all its y movement
but i wouldnt know any other way
btw does anyone know why minecrafts coordinate system is non Cartesian? Like why is vertical y and z is on the plane?
if I sleep a thread I am opening to do something else, it wont affect the main thread correct?
yes
Yes it will affect or yes it will not affect?
Sorry for bumping but still can't find an answer for this ^
yeah, like as you said, its ANOTHER thread
it will not affect it
Alright thank you!
Although
Yes, just had to make sure.
depends
unless you do Bukkit.runTask
or its sending chat messages
but most things in the api are not thread safe
Should work
declaration: package: org.bukkit.enchantments, class: EnchantmentOffer
So to actually use Spigot's API I would have to do Bukkit.runTask() and do it from there right?
yeah I guessed so, but does not change a thing other then it's display name
In the thread, yes.
show the entire function please
(only in table)
Whatever is in the Bukkit.runTask() runnable runs on the main thread
to understand: Bukkit.runTask executes the given Runnable on the mainthread
@EventHandler
void prepareItemEnchantEvent(PrepareItemEnchantEvent e) {
Player p = e.getEnchanter();
p.sendMessage("=== PrepareItemEnchantEvent ===");
p.sendMessage("getEnchantBlock() -> " + e.getEnchantBlock());
p.sendMessage("getEnchantmentBonus() -> " + e.getEnchantmentBonus());
p.sendMessage("getOffers() -> ");
for(EnchantmentOffer o : e.getOffers()) {
if(o == null) p.sendMessage(" null");
else p.sendMessage(" " + o.getEnchantment() + String.format(" [%d]", o.getEnchantmentLevel()));
}
p.sendMessage("\n\n");
e.getOffers()[0].setEnchantment(Enchantment.KNOCKBACK);
e.getOffers()[0].setEnchantmentLevel(5);
e.getOffers()[0].setCost(60);
}
Sounds good thanks. I actually had planned sending a message jaja
?paste
Also instead of making threads you should use bukkits system with runTaskAynchronously
Alright thank you
Sending a message might actually be fine
Ive heard that the chat runs on a different thread
but I might be wrong
but dont try messing with inventories
Well yes but I am using Callables and Future
Alright thank you.
but be aware of the 1 tick delay
I am sleeping the thread for a second and every seconds messaging the player
in that thread
but I call the Bukkit.runTask
I should be fine right?
why not just use BUkkit.runTaskLater
Because I need to know if the current task was successful or not
I need runnable to return a value
and Callables can actually do that
and I want it to wait for its value then do something and I am using Future for that
Uhhh
CompletableFuture is pretty much all you need
Although you might have to pair it with a latch for some more complex systems (Packet system that sends a request and provides a CompletableFuture of the reply, for example)
Oh okay I didn't know that, Thank you!
https://hastebin.de/ceropolija.properties anyone know what this is from?
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class ReloadNoInvis implements CommandExecutor {
private NoInvis noe;
public ReloadNoInvis(NoInvis noe) {
this.noe = noe;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.isOp()) {
noe.reloadConfig();
sender.sendMessage("Reloaded NoInvis.");
}
return false;
}
}```
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.session.SessionManager;
public class NoInvis extends JavaPlugin {
ConsoleCommandSender console = getServer().getConsoleSender();
@Override
public void onEnable() {
console.sendMessage(ChatColor.GREEN + "NoInvis started successfully! " + ChatColor.DARK_PURPLE
+ "Made by Pray on 11/5/2021, Version: 1.0");
getConfig().options().copyDefaults();
saveDefaultConfig();
getConfig().createSection("no-invis-in-pvp");
getConfig().set("no-invis-in-pvp.enabled", true);
getConfig().set("no-invis-in-pvp.message", "&e(!) &cInvisibility is disabled in pvp!");
getConfig().createSection("no-harm-in-pvp");
getConfig().set("no-harm-in-pvp.enabled", true);
getConfig().set("no-harm-in-pvp.message", "&e(!) &cInstant Harming is disabled in pvp!");
saveConfig();
initCmds();
initEvents();
SessionManager sessionManager = WorldGuard.getInstance().getPlatform().getSessionManager();
sessionManager.registerHandler(CustomHandler.FACTORY, null);
}
public void initCmds() {
getCommand("noinvisreload").setExecutor(new ReloadNoInvis(this));
}
public void initEvents() {
getServer().getPluginManager().registerEvents(new Listeners(this), this);
}
}
you have two plugins defining the same class
use proper package names
me.pray is not a proper package name
Hey, I have this function that loops throguh a given Map Im trying to make it only loop for the first ten times. this is my current code but its not sending anything at all, ```java
public static int times = 1;
public static void printMap(Map<OfflinePlayer, Integer> map, Player p)
{
for (Map.Entry<OfflinePlayer, Integer> entry : map.entrySet())
{
if (times <= 11){
return;
} else {
p.sendMessage(ChatColor.GOLD + "#" + times + " " + entry.getKey().getName() + " " + entry.getValue());
times++;
}
}
}``` the map contains data and all.
a static variable for a counter seems problematic
How so? im not too familliar with the differences?
also you are returning if times is smaller or equal to 11
OH
well, you'd have to reset that variable
after the method is run once it would be stuck at 12
hopefully
or well, 11
just define that variable in the method itself
alright
additionally, maps do not have the concept of order @subtle folio
hashmap has no sort
well i made it sort
you wouldn't be using a hashmap anyway if you were sorting it somewhere
I mean I guess you could sort a tree map
treemap is sorted by default
yea but you'd need a custom sorting function usually
Make sure to use linked hashmap if you're sorting 🙂
if times <= 11 you return
flip it
yea I think they got it xD
ok i didnt read
yup thanks for checking it
I also just suggesting doing a continue and not shoving the code in an if else
is there a differnece for me?
you should stick to return
continue would keep on iterating over the rest of entries even tho none of them are eligible to be printed.
oh yeah not continue, return
but separate it
i guess its up to you, compiler will fix it anyway
but usually doing the check that ends the code execution first is cleaner
then no need to indent the message and int increment
why are you defining public static int times = 1 outside the method
fixed this already.
ah sorry chat didint update
👌
i just saw the messages lol
hey friends, ive got some console issue when running the commands now, https://www.toptal.com/developers/hastebin/asaxoxubul.md
lmk what files you need to see bc i cant decipher these errors
oh sweet thanks
at net.ntdi.tazpvp.commands.playercommands.lbLevelCommand.printMap(lbLevelCommand.java:70) ~[?:?]
at net.ntdi.tazpvp.commands.playercommands.lbLevelCommand.onCommand(lbLevelCommand.java:33) ~[?:?]
ive figured out the issue, im using entry.getKey().getPlayer().hasPermission("perm"){ to find out if the entry had a perm but its not liking that
is there a way to do the same thing
entry.getKey() is a offlinPplayer
kk
and then check if p.hasperm
let me check
try that
OfflinePlayer player = Bukkit.getServer().getOfflinePlayer(<player name or UUID>);
player.hasPermission("some.permission.node");
that didnt work?
i dont see why you would need vault tbh
How can I put a custom message where the music would play?
uhhh
I mean you could intercept the item click event
check if the item is a music disc being clicked on a jukebox
then display the text via an actionbar API like modern Spigot, Adventure, or ActionBarAPI
I just want to play it
i dont mean when clicking the jukebox
just like if someone types a command
not in basegame
then just display it via an actionbar API like I said :p
k
newer Spigot supports it by default
Player.spigot.sendMessage with ChatMessageType.ACTION_BAR iirc
thanks!
what is the packet limit for minecraft client?
like how many packets can be send in 1 second
i think that it is unlimited
i use brave
not firefox
fire fox 😫
My condolences
im not sure the exact number but at one point i tried sending ~100 a second and was getting a "too many packets" error
it probably depends on the client and server
Viaversion, or spigot default limit
Well if we turn of spigot limit then maybe unlimited i think
Yeah probably but not a good idea to surpass it
Anyone here ever worked with building a resourcepack from INSIDE of the plugin jar. (i.e I want to dynamically create my resource pack then let the player load it)
just curious as to how to approach it
I imagine you simply create it in the data folder and then zip it using Java’s zipfile methods
Sending it to the player is a bit more complicated
I'm trying to make a fake player rotates smoothly and in sync, but this is what I got right now.
Code: https://paste.md-5.net/conehageka.cs
the body part is going crazy man
I need help I have a survival world and I have a little spawn area when you join the world And Idk how to have them spawn there when they join the world for the first time and ones they go to there bed they don’t spawn there no more
Cant you send unlimited packets on server side?
yes indian tech support is here pay 100000 ruupees and get a free antivirus!!
omg free anti virus?
very much
how can i make top10 with data in a yml
the uptime is kinda sad
Oh
Does that gets the tps low?
That's why big servers have a daily restart 🤠
yes!
Wew
doesnt matter, ur ram is overkill
Just say them bye bye
Whoa
no lmfao
Noo
Imagine using 1 tb
:/
im a dev on a server that reaches 5 tps if not restarted in 24 hours
[09:00:21 WARN]: Can't keep up! Is the server overloaded? Running 5007ms or 100 ticks behind
already
Theres a website which tells you how many ram to use depending on the amount of players and plugins
thats fine, let it stabilize
what a waste
even md_5 doesnt want overkill servers
[09:01:24 INFO]: TPS from last 1m, 5m, 15m: 17.23, 19.11, 19.69?
for 32 bit its like 2gb 64bit is heaps more
anything over 12gb for a server is a waste
whow, is someone making a lag machine? try tp'ing to everyone
and see what they doing
if you have the infrastructure to support 12gb+ per server you should be server meshing
prolly even hypixel mega lobbies dont have 20gb of ram
they are hella optimised
i have anti redstone clock pl tho
fax
there could be bypasses
also there are other types of lag machines
such as armor stands
that is why i have ArmorStand-Limiter v1.4.jar
all plugins have bypasses!
how does it limit them tho?
how many plugins you have?
ok whats ur tps rn?
14.56
i found 0 lagg mashineee
decreasing?
ram?
if its slowly going down it means theres a mem leak
no, tps
decrease max mobs in 1 chunk
how?
entity-activation-range:
animals: 16
monsters: 24
raiders: 48
misc: 8
water: 16
villagers: 32
flying-monsters: 32
villagers-work-immunity-after: 100
villagers-work-immunity-for: 20
villagers-active-for-panic: true
tick-inactive-villagers: false
wake-up-inactive:
animals-max-per-tick: 4
animals-every: 1200
animals-for: 100
monsters-max-per-tick: 8
monsters-every: 400
monsters-for: 100
villagers-max-per-tick: 4
villagers-every: 600
villagers-for: 100
flying-monsters-max-per-tick: 8
flying-monsters-every: 200
flying-monsters-for: 100
=
oh 17 tps
```yml
code
```
spawn-limits:
monsters: 25
animals: 8
water-animals: 7
water-ambient: 8
ambient: 1
chunk-gc:
period-in-ticks: 400
ticks-per:
animal-spawns: 400
monster-spawns: 1
water-spawns: 1
water-ambient-spawns: 1
ambient-spawns: 1
autosave: 6000
aliases: now-in-commands.yml
or?
this
yes
what do i change it to?
slash it like 5 times
yes, divide monsters by 5
i dont know math
on the monsters?
yes
might as well double autosave
12000?
yeah
and then restart?
nope
Maybe that for #help-server
oke
then?
u can restart
[09:13:30 INFO]: <ClownPiecre> NO
[09:13:32 INFO]: <Kawaii_Chans> DONT
[09:13:32 INFO]: <ClownPiecre> dont restart
[09:13:33 INFO]: <~ZelZOO> done
[09:13:34 INFO]: <~Le_Savage> poek come
[09:13:35 INFO]: <~ZelZOO> u eat
lo0l
tell them to fuck off and restart
And goto #help-server :)
welp that isn't really a great way to choose ram, you just need to test it, because 100+ plugins can be really lightweight while 1 plugin can be super heavy lel
Yea true ofcourse you need to test it
just git gud lol
git gud tf
what
does
this
mean+
09:37:34 [INFO] [Browncars2] disconnected with: Internal Exception: io.netty.handler.codec.EncoderException: java.lang.NullPointerException: Cannot invoke "java.lang.Enum.ordinal()" because "instance" is null
i removed all the via plugins
im making a plugin which changes the xp of the exp bottle if it has an nbt tag, here is my code:
public void onThrowBottle(ExpBottleEvent e) {
if (e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
ItemStack item = p.getItemInUse();
net.minecraft.world.item.ItemStack bottle = CraftItemStack.asNMSCopy(item);
how do i check if the "bottle" has the nbt tag "grand:1b"
What spigot version?
1.17.1
then use PDC
but i want the items to generate into treasure chests too
so ill use loot tables to generate them with nbt tags
PDC is on all items. its a wrapper for nbt tags
wdym
how to use it
?pdc
use a NamespacedKey
idk how to
of your "grand:1b"
new NamespacedKey...
public class Sheep extends EntitySheep {
public Sheep(@NotNull Location location, @NotNull Player player, @NotNull Pet pet) {
super(EntityTypes.ax, ((CraftWorld) Objects.requireNonNull(location.getWorld())).getHandle());
this.setPosition(location.getX(), location.getY(), location.getZ());
this.setHealth(20.0f);
this.ageLocked = true;
this.setBaby(true);
this.setCustomNameVisible(true);
this.setInvulnerable(true);
this.setGoalTarget(((CraftPlayer)player).getHandle(), EntityTargetEvent.TargetReason.CUSTOM, true);
pet.setOwnerUUID(player.getUniqueId());
pet.setOwnUUID(this.getUniqueID());
}
public void initPathfinder(){
this.bP.a(1, new PathfinderGoalPet(this, 1.9, 15));
this.bP.a(0, new PathfinderGoalFloat(this));
this.bP.a(2, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 4.0F));
}
Class object, anyone know how to fix this eror?
not quite right
i dont understand
send the error in pastebin
Okay, wait a second
he is using nbt to create teh items so he uses no plugin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
his actual key is "grand:1b", grand being the plugin in this instance
umm im very new at this i just need to make a new type of grand experience bottle which takes in the xpbottleevent to find when it is thrown
i didnt think it would be this complicated tho
new NamespacedKey("grand", "1b")
NamespacedKey takes plugin and key name
it also accepts two strings
it is deprecated but can be used to create nbt keys
whats the value then?
that value is a type, aka String
yeah as in grand:1b
it is odd to understand yep
idek how nbt tags work but i have seen that the value of the tag doesnt matter much they just use it as a convention
however you are putting the value on your item not using a plugin?
nbt tags are to put it simply a hashmap on an itemstack
ah
yep, teh NamespacedKey is an nbt/plugin name/key
so in this case the namespace is "grand" and the key is "1b" so teh NamespacedKey" is "grand:1b"
The namespaced key just makes it a bit more confusing as it adds another layer of complexity, but its just to make it so keys don't clash
with whatever value is assigned
will this work?
no, you are not looking for a container
oh
if I were you i would just make it key: "expRank" value: "1b" or similar
makes more sense
you are looking for whatever data/value you assigned
if you put a string, then look for a String
out of curiosity what does 1b mean?
there are two bottle types, grand xp bottle, and titanic xp bottle (taken from hypixel skyblock)
so whats the 1b?
i dont really know xD
ohhh
show us where you create your nbt on the item
nicee
figure it out yet?
i had to go for a sec
so new NamespacedKey("bottleType", "grand") would be a string right
it all depends on how you are creating yrou nbt tags in the first place
im sorry if this bothers you im really new at this
this is the give command
/give @p experience_bottle{display:{Name:'{"text":"Grand Experience Bottle","color":"blue","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}'},bottleType:grand} 1
the nbt tag
then yes
okk
I'm talking about reading if from the PDC api
for some reason item.getPersistentDataContainer is not applicable, whats the point of getting the data from the player?
uh idk
you shoudl not be getting it from teh player
you should be reading the PDC from the bottle
Its nowe
not
he's not using a plugin to add it
so his plugin is not in the key
he's using vanilla commands to create an item with nbt
exactly
but when i do it i get erro
yeah the namespace still shouldn't be used AS a key
I believe the PDC is in teh ItemMeta
What are you trying to do
you shouldnt use that namespacedkey constructor
if you are going by this, that wont work
why not
why not? and what should i use then?
like i said before you are using namespace as the key
in your example key = bottleType value = grand
ok, so what should i do?
yeah
its the same equivalent as using a hashmap just for the key
you need to check the value
you added it using vanilla commands so your NamespacedKey is actually "minecraft:bottleType" I believe
your namespace is minecraft, yoru key is bottleType
oh
he's adding using vanilla commands so it is in the minecraft namespace
I'm trying to make a fake player rotates smoothly and in sync (body and head), but this is what I got right now.
Code: https://paste.md-5.net/conehageka.cs
Nbt tags in minecraft doesnt have namespace by default
dont know if theres a spigot equiv but you can use packets to control both head and body rotation
Thats not how pdc looks like in nbt
they shoudl be added using teh default minecraft namespace
can you send an example
Why? Just use plugin namespace in command
namespaced key is purely bukkit
wdym
Do you know the packet?
PacketPlayOutEntityLook, PacketPlayOutEntityHeadRotation
thats not how you add pdc tags with command.
pdc data is in PublicBukkitValues compound
private EntityType entity;
private String name;
private boolean glow;
private int borderSize;
public Overworld(Wife plugin){
this.entity = EntityType.valueOf(plugin.getConfig().getString("overworld.borderMob"));
this.name = Utilities.color(plugin.getConfig().getString("overworld.borderMobName"));
this.glow = plugin.getConfig().getBoolean("overworld.borderMobGlow");
this.borderSize = plugin.getConfig().getInt("overworld.borderSize");
}
public void spawnMob(Location location){
}
I want to get the entity type as an entity so I can set everything.
/give @p experience_bottle{display:{Name:'{"text":"Grand Experience Bottle","color":"blue","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}'}, PublicBukkitValues:{"plugin:bottle_type":"grand"}} 1
thanks gepron1x
How would i do this.
you spawn entity with that entitytype
thats it
How would I do that, It won't let me spawn anything.
World.spawn
I want to get the entity type as an entity so I can set it's custom name.
as i already told you, spawn the entity first
entity type and entity are different things
I know, then how then will I access it?
It returns the entity
thanks
the code remains the same tho, right?
Actually the one that takes an entity type returns a generic entity
But you can use EntityType.getEntityClass
Something like that anyway
How do you route events to other classes in a smart way? so like if I have a BossUtils listener that registers the EntityDamageByEntityEvent() listener, how would you pass that down to various boss classes depending on which boss it is?
Currently I'm doing it the dumb way and using EntityDamageByEntityEvent() in each of my classes.
Huh, thanks.
Just create a method that takes the event as a parameter
Did anyone know why the rotation of 2 characters model (Steve and Alex) is different even tho the value is the same?
can you give me an example, i follow but am unsure of the syntax for storing an event like that
public void whatever(EntityDamageEvent event)
I guess I need to create a list of like boss names, and on attack, check name, and send to the right class if so
or on boss class create, register the boss name and event?
ah i guess that's the way to do it!
Won’t that still be the generic entity ?
so like a hashmap of <String bossname, Event>
yeah but how would you tie that inside each boss class to the main single listener?
call it from the listener
no. meta.getPdc().get(new NamespacedKey(plugin, "bottle_type"), STRING).equals("grade")
In command you'd have to also replace "plugin" with your lowercase plugin name
I understand what you're saying, but maybe you're not following what I'm trying to do. I'm already registering the listener once, but I'd like to pass those around dynamically to other boss classes without having to setup a bunch of if bossname == then bossname.attack(eventData)...
So have an attack method in each boss class
Then you just need to call attack on all your boss classes from within the event
thank you so much
pluginn name or the main class?
plugin name in plugin.yml
ok, so i'm new using vectors and I would like some help using them...
public boolean runCircle(Location loc, float radius, float speed) {
for (double t = 0; t < 7; t += 0.1){
float x = radius * (float) Math.sin(t);
float z = radius * (float) Math.cos(t);
ArmorStand circle = (ArmorStand) Bukkit.getWorld("world").spawnEntity(new Location(loc.getWorld(), (float) loc.getX() + x, (float) loc.getY(), loc.getZ() + z), EntityType.ARMOR_STAND);
circle.setVisible(false);
circle.setGravity(false);
circle.setMarker(true);
circle.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
circle.setVelocity(speed);
}
return false;
}```
What else do i have to set in ``circle.setVelocity``? location i guess?
this doesn't help
okay
and if i set Vector speed
i get an error here:
java } else if (args.length == 1) { int velocity = Integer.parseInt(args[0]); if (args[0].equalsIgnoreCase(String.valueOf(velocity))); return runCircle(player.getLocation(), 3.5F, velocity); }
wdym
with Vector speed i mean this: public boolean runCircle(Location loc, float radius, Vector speed) {
and why is your t 7? it normally just goes up to 1
because if not, it doesn't create a full circle
ohh, now i see it. circle is the armorstand
velocity is the knockback you give them. get their location as a vector and multiply it
How i can get the string id of an item stack?
oh
velocity is that
itemstack doesnt have an id iirc
just the material has
their location as a vector and multiply?
in lower versions at least
i am not sure, you could try it.
circle.getLocation().toVector().multiply(1)
the double in multiply
circle.getLocation().getDirection()
yeah
but probably what elgar said makes more sense
but then your armorstand have to look into the direction you want to push it
how are you trying to move the stand? in what direction?
in a circle
around what?
¯_(ツ)_/¯
ah
How would you repeat this in a smarter way?
public void onBossDeath(EntityDeathEvent event) {
if (event.getEntity().getName().equals(boss1Name)) {
boss1Death(event.getEntity());
} else if (event.getEntity().getName().equals(boss2Name)) {
boss2Death(event.getEntity());
} else if (event.getEntity().getName().equals(boss3Name)) {
boss3Death(event.getEntity());
... halp me!!!
}
this is without a number
Create an interface class?
and if i specify a number i don't apreciate a movement or it's not being done
How i can get the NBT tags of an item as string?
You'd have to use nms
your method looks a bit wrong for letting an armorstand move around your circle
can you link an example or something? i have no idea what you mean. OO isn't something i'm super familiar with so i could use a little hand here...
you spawn the armorstand in the method and then spawn a circle right away expecting the armorstand to move around in that circle
your armorstand will just be pushed 100 times and then stop
you probably have to cache the locations of the circle points and let it move around in a scheduler
i spawn them away and then i teleport to the player so they don't see the animation of converting invisible the armorstand
no?
an Interface Class uses Extends ...? sorry, dumb questions... trying to get smarter!
a yeah, no. 100 armorstand will be spawned and pushed around 🙈
why
Let's open a thread
okay wait, i got something wrong here. the armorstands are those floating blocks.
so thats probably fine
How to make this smarter...
ok xD
but to let them move in a circle you have to cache them
so you can reuse them and let them move
doesn't this: circle.getLocation().toVector().multiply(speed); get the armor stands and make them move?
yeah as i said, one time and then never again
but i guess you want to keep them moving
its more or less the same
It does not exist
i don't remember for what schdule was, but now i get it. will read about that
thank you very much!
https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/
See developer notes
Would anyone have an idea how to make custom roles that give permissions to player who have these roles?
P.S. I want to make these roles with my plugin (to code it) not with another plugin such as LuckyPerms
how do i generate plugin.yml
um i dont know how that works
name: NAME
version: 1.0
author: AUTHOR
main: whatever.your.package.class
no i mean, how do i get it to generate when the server is run
um when i use my server, there is no folder generated with plugin.yml

plugin.yml is not generated
teh plugin maker makes it
and puts it in the jar
so that the server knows how to load the plugin
and how do i do that
Like this
What does "teh" mean
ah LoL
Hey is possible detect idcplayer skin model ir alex or steve?
There is a way to do it without nms?
No
@quaint mantle it still doesnt work ;-;
my code
package net.fordium.xpbottles.events;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ExpBottleEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
public class GrandXp implements Listener {
@EventHandler
public void onThrowBottle(ExpBottleEvent e) {
System.out.println("bottle print event");
if (e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
ItemStack item = p.getItemInUse();
ItemMeta meta = item.getItemMeta();
PersistentDataContainer container = meta.getPersistentDataContainer();
if (container.get(new NamespacedKey("XpBottles", "bottleType"), PersistentDataType.STRING).equals("grand")) {
e.setExperience(1395);
}
}
}
}
bottle_type instewd of bottleType
why does that make a difference>
Oke
Namespaced keys can’t have caps
OH
And use a plugin when you create namespaced key
wdym
also
still doesnt work
Show the command
/give @p experience_bottle{display:{Name:'{"text":"Grand Experience Bottle","color":"blue","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}'}, PublicBukkitValues:{"XpBottles:bottle_type":"grand"}} 1
Namespace should be lowercase
yes i put it bottle_type
what else?
Your plugin name
Thats namespace
but that means ill have to keep the plugin name short?
no?
then what's the problem
just change it in namespace?
XpBottle -> xpbottle
please dont mind my stupidness im really an amateaur
in the command...
okay
and for the love dont use the deprecated constructor
what then?
Plz anyone?
NamespacedKey(Plugin, String)
so in plugin i should go new Main() ?
you can get the uuid with username
no. Already existing plugin instance
No, you aren’t allowed to create a new instance of your main
no you are not allowed to do that
?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.
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
um i dont want to learn java, im not a plugin dev, just wanna make a single simple plugin to add new xp bottles to my private server
thats it
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
"private server"
And?
so its obvious i wouldnt be willing to spend much money on it
if its not much to do you will also find someone making it for a vouch
oh if someone can make it for a vouch then suree
but who will?
?services anyone here
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
there are alot of people offering a small free plugin for a vouch
but do i ask someone to do it for a vouch or are ppl advertising they would do it for a vouch
https://www.spigotmc.org/forums/offering-developers.59/ look it up yourself
Then how do you expect to make a plugin without learning java lol?
oka
visual bukkit 
i know other programming languages like python and cpp and bit of c# and i made other simple plugins too
Hey how do I iterate through all chunks inside of a world border?
for (chunk c : world.getchunks)?
But every api is diffrent and u need 2 invest a bit time lel
xD
what is so funny about it now^^
How do I get the contents of a book inside of a lectern?
Get the BlockState and cast it to the Lectern then get inv and book
how can i send a player a message where only one part is underlined?
yea but now player with name Proscreeam1337 don't exists
Break down message into multiple components and set the underlined decoration only on part you need?
ChatColor.DARK_GREEN + "text" + ChatColor.GREEN + "" + ChatColor.UNDERLINE + "underlined" + ChatColor.DARK_GREEN + "text"
thats what i wrote but somehow the first text is also underlined
how to spawn an entity at the loc of where you right click
i figured out on how to spawn the entity but idk how to make it spawn at the loc of where you right click
Listen to PlayerInteractEvent
^ Get the right clicked block and get it's location
how?
What part
how to get the right clicked block
and then .getLocation ?
Yes
so the result would be event#getClickedBlock().getLocation()
There you go, you got your location
Are chunks 16 or 256 Blocks high?
256
p.getWorld().setThundering(true);
p.getWorld().setThunderDuration(2*60*2);
This wont work, i wana die
Why the method ItemMeta#getDisplayName returns me an empty string?
Someone can give me help plz
how i can get the name of an material then?
sadly you cant really do much with spigot
#getType().name() returns the material name of an item
in a string
I think itemstacks have that
its an enum
true
You gotta make it rain too
what does .getPlayer().getPlayer() even does?
Nothing
thats because Player extends OfflinePlayer
oh
i unserstand
well whats you idea?
I am trying to make a idea of where when you spawn in the server you get a random amount of hearts ranging from 6-12
you need player.setHealth() for that
Hey guys, what do I have to add to my code if I don’t want to destroy the block protected by other blocks?
(for example: protect a block of dirt that is covered with obsidian)
public void onExplode(EntityExplodeEvent e) {
List<String> blocks = new ArrayList<String>();
blocks = Main.plugin.getConfig().getStringList("blocks");
for (Block block : new ArrayList<Block>(e.blockList())) {
if (!blocks.contains(block.getType().toString())) {
e.blockList().remove(block);
}
}
(blocks is a list of block that won't explode)
It does not work very well, instead of "Spruce Planks" retuns "Wood"
unlucky
Hey can someone help me
what
I am trying to make a idea of where when you spawn in the server you get a random amount of hearts ranging from 6-12
If someone can assist me in this please dm me!
you need a Random object for that
Yep, either use Random or ThreadLocalRandom.current()
@Eventhandler
public void onJoin(PlayerJoinEvent event) {
Random random = new Random();
event.getPlayer().setHealth(random.nextInt(7) + 6);
}```
something like this
that would go from 6 to 12 right?
how to make cooldowns
like command cooldowns
event cooldowns
give some ideas pls
with a timestamp
how
store players in a map
so a map<uuid, long>
and you store the time when they used that command the last time
@last ledge can you help me?
like System.currenTimeMillis()
nobody can help me ?
cancel the event based on the block that may not explode
i dunno if a BlockBreakEvent gets fired when tnt explodes
public void onExplode(EntityExplodeEvent e) {
List<String> blocks = new ArrayList<String>();
blocks = Main.plugin.getConfig().getStringList("blocks");
for (Block block : new ArrayList<Block>(e.blockList())) {
if (!blocks.contains(block.getType().toString())) {
e.blockList().remove(block);
} e.setCancelled(true);
}
like this ??
you can modify the list to prevent certain blocks being blown up
that for loop with error will a concurrent modification error
ah new array, you are ok
So I made this Group enum https://pastebin.com/StEQmJFz
And each player can be in one of the groups...
What I'm looking for is a way for someone to write the usernames in a file, and when the player with the matching username connects, it automatically gives him a group.
The Group of a player is saved in his datamap right here:
- Data: https://pastebin.com/7fsT0nCA
- Manager: https://pastebin.com/wriZy4jM
(for example, let's say I write down the username Flow_ in the team_two file, then when Flow_ will connect to my server for the first time, it will automatically give him the group TEAM_TWO
lombok the way to go :kekw:
didn't work
now there is no explosion lol
https://imgur.com/a/u71ESx7 Im getting flung after I get killed whenever I force a respawn with this p.spigot().respawn(); ive tried both p.setVelocity(new Vector(0, 0, 0)); p.teleport(new Location(Bukkit.getWorld("spawn"), 0.5, 50, 0.5, 180, 0)); any ideas on how to fix?
maybe there is a way to prevent the block from breaking
Why do you need equalsTo
There's already equals method in enum which works perfectly
ok
i want to send a message to a player where one part is underlined
ChatColor.DARK_GREEN + "text" + ChatColor.GREEN + "" + ChatColor.UNDERLINE + "underlined" + ChatColor.DARK_GREEN + "text"
i wrote this but somehow the first text also gets underlined in green. how can i only underline the middle part?
why is AsyncPlayerChat depreciated, whats the alternative for it
use Chattranslate and use &u for underline ig
&u or something is like that for underline
check in google
ok thanks
Are you on paper
yes
See deprecation note
declare a dependency on JetBrains Annotations
@EventHandler
public void onChat(AsyncChatEvent event){
Player player = event.getPlayer();
player.
}
}```
I am trying to get player's message
but there is no option in ``player.``
Use AsyncChatEvent#getMessage()
Does anyone know how i can stop the bedrock portal from spawning after killing a dragon?
So I have a string that looks like minecraft:grass[snowy=false] and the like and I want to parse the tags in the brackets how would I do that?
regex
I don't know how to use regex
dont ask me how 😳
doing that in regex would be hard
you'd wanna substring the [] part, then split by the tag's delimiter to get each pair
would it just be \\[ to split everything after the square bracket?
and then if you need the name and value by themselves, split by =
and cast the second part to a boolean
doesnt work
plus, valueOf handles improper values too via exception
Say I have a stick with an nbt tag "stick:1b"...
I have this code to get the player inventory on say an entity hit event
@EventHandler
public void onEntityHit(PlayerInteractEntityEvent e) {
Player player = e.getPlayer();
ItemStack stack = player.getItemInUse();
ItemMeta meta = stack.getItemMeta();
}
now how do I check if the "Stack" item is the stick with the nbt tag "stick:1b"
You must be using it wrong, https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/AsyncPlayerChatEvent.html#getMessage()
declaration: package: org.bukkit.event.player, class: AsyncPlayerChatEvent
So I made this Group enum https://pastebin.com/iimATpF5
And each player can be in one of the groups...
What I'm looking for is a way for someone to write the usernames in a file, and when the player with the matching username connects, it automatically gives him a group.
The Group of a player is saved in his datamap right here:
- Data: https://pastebin.com/7fsT0nCA
- Manager: https://pastebin.com/QX0Qh3XB
(for example, let's say I write down the usernameFlow_in theteam_twofile, then whenFlow_will connect to my server for the first time, it will automatically give him the groupTEAM_TWO
write the enum's name to the file as well via name()
and then when the file is loaded, Group.valueOf
if you wanna be safe, when loading the group's name from the file, you can do toUppercase() as valueOf requires the names match 1-1.
is it possible to set a world name to string in configuration files? (toString isnt working)
