#help-development
1 messages · Page 1552 of 1
then just set the one specific block to air
so the blocks that are fire
instead of all of them
not the fire block
wait what are you trying to do here
extinguish multiple fires or just one
just the one.
so a projectile hits a block, sets it on fire
that fire goes for 15 seconds
after 15 seconds i'm trying to extinguish the fire, but only the fire. not removing the blocks. yes i know some blocks burn within that 15 seconds that's fine though
set the fire block to air
Can block at 255 be set on fire on the top
no because the fire would have to occupy 256 which exceeds the world size
fire isn't an entity; it's a block and needs to occupy an entire block of space
i wonder is the fire will go out before 15 secs
like natrually
or burn the block away
projectilehit -> getLoc,set fire, execute the runnable and feed the location of the fire block to it so it can set the block to air in 15 sec
i will not extinguish all fires if you do it correctly
is there a way to make a line of code where there are no tall grass blocks in the world
very difficult to do in a single line of code
remove the block populator that spawns them from the generator
yes there is a way
idk how to do that
then you should learn how to do that
or set all tallgrass to air on chunk load (worse method, probbaly easier?)
🤣
how
bru indeed
spoonfeeding is frowned upon
omg i cant believe NNY the 7 years old know about the generators
:0
aww online chat is no fun
cant see live reactions
for(Block nearby : getNearbyBlocks(block.getLocation(), 15)) {
if(nearby.getType() == Material.FIRE) {
if(nearby.getBlockData() instanceof Fire) {
//Fire fire = (Fire) nearby;
//fire.setAge(15);
nearby.setType(Material.AIR);
}
}
}
});```
so checking to see if the block is instance of Fire and the material still removes that block thats currently on fire (under the Fire)
Trying to put out the fire after 15 seconds and not remove the blocks that are under the fire when setting the fire to Material.AIR. as some of the blocks may not have been 100% burnt at the end of that 15 seconds.
what i've currently got now works but it also removes the block that the fire is sitting on
correct, i don't want to remove it
Alright so when you set the nearby to air it's removing the block underneath?
yeah, all blocks that are on fire get removed plus the block that the fire sits on.
What version are you running for the server
1.16.4
why are you running .4
it's what my test server has been running on for a while, i'll update it and see if that fixes
it probably won't
I don't think upgrading will fix but you wan to upgrade .5 added stability fixes
i super vaguely do remember hearing someone mentioning something about some strange vanilla logick that'd consider a burning block as burnt when the fire on top of it is removed manually
Honestly I don't know what the issue is with the fire thing as the fire javadocs are fucking shit
i thought casting it to Fire from the blockData and setting the age would work
Literally the description of Fire is md_5's mixtape
yeah i seen that
Gonna see if paper docs offer any better info
thank you for your help and everyone else
It does not.
they generally don't care to touch up the shit that spigot left to rot
ill just settle for what it does now, thank you everyone
only the new stuff has proper docs
Def try .5, see if that helps, if it doesn't try paper possibly as maybe they have a fix for it
alright
Still not found any reason why this could be happening. Anybody got any ideas?
i want to make a plugin for 1.7.10 does anyone have a link for the right spigot download
Hi. I am working on a plugin.. I have the following code in my onjoin() event and I was wondering if anyone can help me figure out how to get this to work>?
What is not working
the teams dont show up in team list or tab menu
so do you guys know how to fix it or do it another way?
Got it to show up just gotta get it to show the prefix
on tab menu
which still doesnt seem to work for some reason
How do I create multiple servers on one host? Like what minigame servers have. (making a minigame plugin rn and need to switch between servers)
Is it possible to add log4j settings for the Bukkit logger from a plugin? I'm trying to silence logs from a specific package but I can't find a way to add the log4j setting in the plugin itself
i found out when you use the thing to simulate another device in devtools on google it actually sends to the website that your on mobile
this is the javascript lmao https://paste.md-5.net/raw/nejeyoyuxa.js https://paste.md-5.net/nejeyoyuxa.js
i found this online
lmao
public static void updateScoreBoard(Player p) {
if (CitizensAPI.getNPCRegistry().isNPC(p)) {
Bukkit.broadcastMessage("npc"); // this doesn't get called, i guess NPCs aren't included in bukkit's getonlineplayers method
return;
}
Objective health = score.getObjective("showhealth") == null ? score.registerNewObjective("showhealth", "health") : score.getObjective("showhealth");
if (health.getDisplaySlot() != DisplaySlot.BELOW_NAME) health.setDisplaySlot(DisplaySlot.BELOW_NAME);
health.setDisplayName(SkyblockBasics.replaceChatColors("&c❤"));
p.setScoreboard(score);
}
for (Player p : Bukkit.getOnlinePlayers()) {
Scoreboard.updateScoreBoard(p);
}```
is there any way to fix this with citizens NPCs https://prnt.sc/n8ph6k
not possible
unless you had a custom client
hypixel and several other servers do it
they dont
well its not possible
i believe it showed for me so maybe thats badlion or whatever client your using doing that
but let me tell you its impossible cuz the above name scoreboards are client sided all the info is grabbed from the server
player to my right with healthbar, npc further forward with no healthbar
i'm on vanilla
so, it is possible one way or another
it isnt tho
i'm legit showing you
then that means nms would do the job?
no
i'm stumped
its not possible
several servers pull this off. hypixel isn't one of a kind
and not every server uses some modified server jar
or they might, but it'd at least be public since not everyone has the money or expertise to do that
its not possible
you just said it's possible with a custom server
i said might idk if it is or not
but im telling you u cant do it with nms or with just the spigot api
well someone in this discord's gotta have the answer ig
if this was possible it would be in the citizens config
to disable health above name
citizens faq does not provide info on how to fix the issue, rather to just disable it
yeah cuz it isnt possible
but they do say you're able to get in touch with the plugin dev for an alternative
nah
^^
well hypixel probably fixes it by using internal plugins
name of npc is invisible, idk how they pulled that off or what
but it's just it seems a hologram on top of the npc
its not possible lol
which wont randomly create stuff
and hypixel prolly does the same
so on that note
is it possible to make the npc's nametags and stuff invisible?
great
should make the name invis
i think i'll have to use an outside plugin for that like nonamenpc ig
seems like that plugin's only limited to 1.8.8 tho and no idea why
wdym
idk at all how protocol lib's used
what exactly do you mean by "custom names"
try /npc name ? with nothing after it
nah it'll just give me an argument error
ah it said somewhere dev builds allow you to do it with nothing
isn't that premium tho
¯_(ツ)_/¯
so im doing this plugin where like the last player alive wins and I want it to show a title saying victory on the last player alive can someone help me
is it possible to use code to check if a certain gmail account (in config file) is subscribed to a youtube channel
so as to people subscribe to a youtube channel before using some plugins
I imagine that it is possible with some oauth stuff
But YouTube doesn’t publicly share emails thankfully
i mean cuz i need to find a way to get large amount of sub outside of YouTube, or else I will never get 1000 sub
But i dont see a api for doing so.... time to really dig into docs
Or maybe buy subs and view hours myself
You don’t even need protocol lib for that
You just inject into the netty pipeline, and check for entity use packet or whatever
PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER?
does sending that packet to the npcs work
or
idek
isnt npcs just fake players
mhm
then if that thing works for players that it might work for npcs
im struggling to figure out how to loop thru all the npcs
citizens api?
soo we'll see in like a few years
yea trying
i'm not really sure what to do about this line
Iterable<NPCRegistry> reg = CitizensAPI.getNPCRegistries();
for (NPCRegistry _reg : reg) {
Iterable<NPC> npc = _reg.sorted();
CraftPlayer _npc = (CraftPlayer) npc.iterator().next(); // since NPC's aren't craftplayers
PacketPlayOutPlayerInfo pack = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, _npc.getHandle());
_npc.getHandle().playerConnection.sendPacket(pack);
}
that's commented
Citizens doesent handle all that for you?
wdym?
best explanation i found on how to loop thru npcs
am i supposed to send this packet to players and not npcs?
since that sounds more logical and possible
Why can’t you just call .destroy
i'm not trying to delete the npc
i'm still on this
If you use scoreboard teams you can set name tag visibility
If you really want it blank
Lol ofc it’s possible
does it disable showhealth objective tho
I’m pretty sure playerinfo packet just takes them off tab btw
Idk what citizens is using
I mean you can try it
Doubt it’ll work, I think “hypixel” did this lol
u dont know hypixel?
Ofc I do
quoted it lol
ill see and lyk
Unless he knows there secrets 🧐
Yea I believe that’ll work
Idk what you gotta do after that tho.
Assign teams and stuff
well idk how to assign the team to the npc
i guess i already got the iteration done
NPCs are treated as players so you add them by name to Teams
by name?
other Entities you add via UUID.toString()
team.add(name)
deprecated
alright
do as Bomp said, add them by name
team.addEntry(replaceChatColors("&e&lCLICK"));
yea and that should be this?
that all?
already registered team, blah, set the scoreboard
that did it <3
thank u
Bettt yw
@EventHandler
public void ChunkDestroyEvent(BlockPlaceEvent e){
Player player = e.getPlayer();
Block block = e.getBlockPlaced();
ItemMeta meta = player.getInventory().getItemInMainHand().getItemMeta();
String name = meta.getDisplayName();
Chunk chunk = block.getLocation().getChunk();
World world = player.getWorld();
if(block.getType()==Material.DIAMOND_BLOCK && name.equalsIgnoreCase(ChatColor.AQUA+"ChunkDestroyer") ){
player.sendMessage("Chunk gone");
int X = chunk.getX() * 16;
int Z = chunk.getZ() * 16;
for (int x = 0; x < X+16; x++) {
for (int z = 0; z < Z+16; z++) {
for (int y = 0; y < 128; y++) {
world.getBlockAt(x, y, z).setType(Material.AIR);
}
}
}
}
}
im trying to make a block but when its placed it destroys a chunk
im not sure if this code is correct
oh lol it works
wait
my server is just slow
oh does it break bedrock though?
ye
imma try and change it then
Good afternoon, could anyone give a link to the simple murder mistery/skywars/bedwars github?
At the moment I am trying to write my own mini-game and would like to see some sample code on how to correctly build the architecture of the application.
Thank's.
Afternoon? It's 9am 🤨
Sorry, I was counting by my time zone 😢
Ah my bad, sorry was a bit confused that's all
Use ASkyBlock it’s a really great plug-in that I have used
BentoBox is a gamemode with a bunch of stuff like bedwars and one block
A bit like a mini game api for devs
It’s all open source too
So you can “borrow” code
hey guys, is it not possible to set default name to a custom item? I'm trying to set a smithing recipe for a custom item but the display name and attack damage won't change (cuz smithing will keep the item meta i guess)
When a somebody uses a smithing table just change the item meta
so I should use prepareSmithingEvent right?
Ill check
or SmithItemEvent
Prepare just triggers when somebody puts an item in a smithing table
Not uses it
So SmithItemEvent is when a user completes an action
For the events read the spigot docs
declaration: package: org.bukkit.event.inventory, class: SmithItemEvent
oh so SmithItemEvent is called when the upgraded item shows up?
When they take the item
Called when the recipe of an Item is completed inside a smithing table.
ummm cuz I want to chanage the item meta after the upgraded item shows up (for preview purpose)
It might be when a preview is made, I dont quite understand the docs
Its worth trying
oh setResult in prepareEvent will help i guess
Try using SmithItemEvent
same here 😂
alright thx ❤️
it's onClickEvent, called after the player took the item
so it's gonna be prepare one
Alright
I'm trying to make a custom tab menu, however I've ran into some difficulty. This will currently add a fake player to every player's tab menu, however I don't know how to reset the tab menu. What I want to do is reset, then reconstruct the tab menu every couple of ticks but I don't know how I can do this/
How to order a MySQL table to top 5 players by balance?
SELECT * FROM tablename LIMIT 3 ORDER BY Balance LIMIT 3?
if you want top 5 why are you limiting to 3?
also don't you need to specify if it's ASC/DESC?
ima assume they googled it
remove the first LIMIT 3
Me and MySQL are not the friends I want It DESC but must I add something for that?
Thx
I think you do ORDER BY Balance DESC LIMIT 3?
@grand coral
I don't know if the syntax is different for MySQL
Ok thx
DIAMOND is not a valid ItemStack
Αn itemstack
a serialized ItemStack
Just save one and check it out
getConfig().set("items.0", new ItemStack(Material.DIAMOND));
anyone know about this?
Update it again
player.getPlayer().hidePlayer();
what is the hideplayer part I can't find it on the API website
just to confirm
comparing 2 UUIDs with .equals() yields the same result as comparing its .toString().equals() right?
yes
ok great
I want to make a team system for some minigames
there's the default mc Teams, however I want to keep track of some additional stuff
so I thought I'd extend Team, went down a rabbit whole of finding out where that actually led and eventually found the CraftTeam class which is private so I can't extend it
so do I just make a wrapper? That's kind of annoying tho
can I just implement Team, or does that break stuff?
why does this not works this time???
I don't see why you wouldn't be able
I extended Command and implemented PluginIdentifiableCommand once
what is the easiest way how to remove /pluginname:command form tabcomplete and only leave the /command?
just start typing the command
???
you can't really get rid of it
there's no way to do that
well you could but why
its made like that so if there are multiple commands with the same name you can use all of them
i can, either by editing the command dispatcher, or by removing it via the send command event, but idk if there is some easy way
or you could just remove the commands from the commandmap
you'd need to use reflection to access the command hashmap though
since it's a protected field
i made all plugins myself, so there are no conflicts between command names and it simply looks better without the plugin name in front of it
default implementation has all this kind of stuff in it
I don't know what it does but it's probably important, so it's probably safer to just wrap
yeah i guess
@waxen barn
@SuppressWarnings("unchecked")
public static void unregisterPrefixes(String prefix) {
try {
final Field f = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
f.setAccessible(true);
final SimpleCommandMap commandMap = (SimpleCommandMap) f.get(Bukkit.getPluginManager());
final Field knownCmds = SimpleCommandMap.class.getDeclaredField("knownCommands");
knownCmds.setAccessible(true);
final HashMap<String, Command> knownCommands = (HashMap<String, Command>) knownCmds.get(commandMap);
for(Map.Entry<String, Command> commandEntry : knownCommands.entrySet()) {
if(commandEntry.getKey().startsWith(prefix)) {
knownCommands.remove(commandEntry.getKey());
}
}
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
look so
this is not the best way
since im doing a for loop and removing from the map at the same time
i'm sure you can do that part better
oh, thanks
1.15.2
if you aren't running this onEnable then you need to sync commands
otherwise it's fine
can i copy the itemmeta of an item or something?
private void completeTrade(Player sender, Player target) {
List<ItemStack> targetItems = new ArrayList<>();
for (ItemStack s : target.getInventory().getContents()) {
if (s.hasItemMeta()) {
// copy itemmeta
}
}
}
s.getMetadata() already results in a clone
Do I have to create a "plugin.yml" for every plugin I have? Or can I use my project to create multiple plugins using only one?
@lament bronze, it doesn't work, probably because as I saied, the hash map is responsible for executing the commands, but the tab list is managed by the command dispatcher, but still I can apply similar logic there.
For every plugin you create, there must be a plugin.yml
Jesus this looks like a mess
well, for every plugin jar - if you bundle plugins into a single jar it isn't needed
then you'd have to sync the commands
the command appears but it says it doesn't exist when you execute it right?
yeah i want to do this
But bundling plugins into a single jar is untypical to say the least at it would result in more work
So, don't try it
I mean is creating a plugin.yml really that hard?
how can I find players who have a particular skin? I'm trying to find players who just have a single colour on their entire skin
have a single class that extends JavaPlugin and the rest are just semi-independent subcomponents of it
I know it takes only 30 seconds to do it, but if something is taking me less than 2 minutes, why not compact or automate?
having multiple classes that extend JavaPlugin is possible, but ultimately not worth the effort
Well you could use annotation processing
Idk if that simplifies the process
🤔 I'm gonna take a look, thanks
but just because something takes less than 2 minutes doesn't mean you can or have the ability to always automate it
Hello guys how do you store the data of a sign? Like if there is a message written in an oak_sign
How will I save it in memory (if u get what I meant :<)
I was thinking to do like this
anything particular?
so?
That is a fully valid plugin.yml - if the intentions behind it are also valid is another thing
Isn't always saved into memory (the 4 lines and if its glowing or not)
Ohh I see
I'm creating a server so I wish I could make just 1 plugin.yml that starts from PluginHeart and go through the other plugins. Basically when the player send /help MCPlugins they get a list of all options they can use. Instead of just multiple projects with just one class/plugin
I mean you could mess with classloaders such that one jar loads all the other jars of yours
Though Idk why you would want that
just to organize things and give up spaghetti code
This just sounds a little bit like a you problem, not to be rude or anything.
All JavaPlugin classes have to be loaded with the bukkit plugin loader - which complicates things
Don't worry, yeah, it is somehow annoying to have to create plugins.yml for every plugin I do, instead of just having one that manages every single one
yeah well I thought of something like papi expansions
ok nvm I've found what I was looking for: https://freshcoal.com/maincollection
The issue is that we have no idea what they are actually doing
How can I prevent a door from opening and closing during the PlayerInteractEvent when it is canceled. Would you have to somehow block with client packets, but how?
or just get the open state in the event and set it back to that after canceling
@eternal oxide didn't know u can do that xd
Canceling door open events is an odd one as even canceling the event can end up ignored by the client, so it ends up open.
yes
ah so you need to sync commands
here
public static void syncCommands() {
try {
Method m = Bukkit.getServer().getClass().getDeclaredMethod("syncCommands");
m.invoke(Bukkit.getServer());
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
run this after you remove the commands
oh, ok
you forgot m.setAccessible(true); but ye, its working
is it rly needed
its public void
yep, it throwed illegalaccessexception without it
huh weird
@waxen barn so what are u doing here
rn nothing, because @lament bronze solved the problem
@waxen barn i mean what were u trying to accomplish 🤔
I was trying to remove the /plugin:command and only keep the /command form of command
.
bec I have tab complete on and it looks nicer without the plugin name
This is a command to give a blue head, how can I find the username or UUID of the player with this head?/give @p minecraft:player_head{display:{Name:"{\"text\":\"Dark blue (#00008B)\"}"},SkullOwner:{Id:[I;1390846929,-1328133163,-1764951099,406210083],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmE0NjA1MzAxMmM2OGYyODlhYmNmYjE3YWI4MDQyZDVhZmJhOTVkY2FhOTljOTljMWUwMzYwODg2ZDM1In19fQ=="}]}}} 1
or does a player with this skull even exist?
I think, that you must loop all players and check if they have this skull in inventory.
try assembling the ID
UUID = new UUID (long mostSigBits, long leastSigBits);
But what is the name of the packet that has to be intercepted?
@river spear just cancel event and set state of doors back to closed like @eternal oxide said
That was my first thought too, but it didn't work out.
Delay it for one thick
how did you set the door open state?
@eternal oxide it ould be he needs to delay task for one thick
yes
he also likely needs to get the other half of the door and do the same
Bisected
how to replace the item that is holding by the cursor on InventoryClickEvent event
I tried...
public void onInventoryClickEvent(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack ClickedItem = event.getCurrentItem();
ClickedItem.removeEnchantment(Enchantment.MENDING);
//I TRIED THESE THINGS:
//event.setCurrentItem(ClickedItem);
//event.setCursor( ClickedItem );
//player.setItemOnCursor(ClickedItem);
//player.updateInventory();
}
I'm just removing the clicked item's mending enchantment and replacing that item stack back to the player's cursor.
TrapDoor door = (TrapDoor) bdata;
door.setOpen(door.isOpen());
Bukkit.getScheduler().runTask(Main.main, () -> {
event.getClickedBlock().setBlockData(door);
});``` no working
what is the best way i can make an abstract class / interface for Kits that my Kit Class will extend/implement
Like Archer Kit extends/implements KitBase
something like that
what do you mean
@river spear delayed tak runnable
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
I mean that is delayed one tick already
Bukkit.getScheduler().runTaskLater(this, () -> {
//your code inside
}, 1);
it will delay 1 tick
runTask schedules it for the next tick
i used runtasklater so we no need to cancel that i think so
@north niche well not sure then
TrapDoor door = (TrapDoor) bdata;
door.setOpen(door.isOpen());
Bukkit.getScheduler().runTaskLater(Main.main, () -> {
event.getClickedBlock().setBlockData(door);
}, 1);```The trap door is still opened and closed briefly
any idea about this ?
@north niche well i was talking about that
That u should cancel event
Then change items
can u send a snippet of it
What is currently a problem
you cancel the event, then set its state in teh delayed task, not the other way around
i just need to replace a itemstack that is holding by the player in his cursor
on "InventoryClickEvent event "
Bukkit.getScheduler().runTaskLater(Main.main, () -> {
BlockData bdata = event.getClickedBlock().getBlockData();
TrapDoor door = (TrapDoor) bdata;
door.setOpen(door.isOpen());
event.getClickedBlock().setBlockData(door);
}, 1);```Still no change
can u explain me short what you are trying to do
Door.isopen
With plugin yml aliases for commands, if you use an alias does it automatically change the command name supplied to the plugin?
No. Cancel the event as normal. You will not be able to access the event inside your runnable as it will be finished. Create a final field for teh data you are going to set and teh block, so they can be accessed in the task
is there any library that contains blocks and items from like 1.7 to 1.17so they are easilly accessible? like getBlock(WHAT, version)
What?
the uuid is this: "52e6a3d1-b0d6-4bd5-96cc-fbc518364623", looking at this website: https://minecraft-heads.com/custom-heads/miscellaneous/6251-dark-blue-00008b
Not really sure what u mean
however this is too short I'm pretty sure
Minecraft UUID and username lookup. Resolve, convert and view name history of any username/UUID today.
typing it in on that website gives nothing
whatcha doing?
oh - i read up
there are changes for items and blocks with versions, like its called another in 1.13 and another in 1.8, most of the things, so is there any library that maps it all
idk
my UUID is "675242d1-5461-4c6f-8017-8353046a44d8"
I'm trying to do tab menu stuff
You asked if the player existed. So I said assemble the UUID, from that you can see if the player exists
well clearly the player doesn't exist, so how do I create a fake player with this ksin?
I'm trying to do this
when I create a game profile the skin is set to the plyaer or whichever UUID I pass in
how to replace the item that is holding by the cursor on InventoryClickEvent event
I tried...
public void onInventoryClickEvent(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack ClickedItem = event.getCurrentItem();
ClickedItem.removeEnchantment(Enchantment.MENDING);
//I TRIED THESE THINGS:
//event.setCurrentItem(ClickedItem);
//event.setCursor( ClickedItem );
//player.setItemOnCursor(ClickedItem);
//player.updateInventory();
}
I'm just removing the clicked item's mending enchantment and replacing that item stack back to the player's cursor.
something like this?
exactly
hey i found this! this was my mistake i was checking this in creative all the time so only it not worked!
Is there a special folder to store plugin data such as databases or config files?
It still doesn't work that it doesn't open and close
Guys, I was thinking... Is it a good idea make an updater that is able to update even the plugin dependency... Bc I've some dependency like the commandManager or the GUIFramework that I use and whenever I change something into the dependency I need to update every plugin... Obv this has the problem that if i remove some methods that my plugins use it will not work anymore.. What I am asking is, Is it worth?
ok what you need to do ? it should need to close automatically after few seconds ?
I don't want the client to see it open
I want the trap door to stay closed in the video I can see that it is open but it is already canceled.
u need to stop packets then
I want to try that too, but what is the name of this packet
check the wiki ig
.
plugin.getDataFolder
where is it located within the server?
@EventHandler
public void ChunkDestroyEvent(BlockPlaceEvent e){
Player player = e.getPlayer();
Block block = e.getBlockPlaced();
ItemMeta meta = player.getInventory().getItemInMainHand().getItemMeta();
String name = meta.getDisplayName();
Chunk chunk = block.getLocation().getChunk();
World world = player.getWorld();
if(block.getType()==Material.DIAMOND_BLOCK && name.equalsIgnoreCase(ChatColor.AQUA+"ChunkDestroyer") ){
player.sendMessage("Chunk gone");
new BukkitRunnable() {
int X = chunk.getX();
int Z = chunk.getZ();
int y = 0;
@Override
public void run() {
world.getBlockAt(X, y, Z).setType(Material.AIR);
X++;
Z++;
y++;
if(X<=X+16){
this.cancel();
}
if(Z<=Z+16){
this.cancel();
}
if(y<=255){
this.cancel();
}
}
}.runTaskTimer(Main.getInstance(),0,1);
}
``` can someone tell me whats wrong here?
plugins/pluginname
Ok, thanks
you have to tell us
?paste

im trying to make a block but when its placed it destroys a chunk
is blockchange right?
https://www.spigotmc.org/resources/fakeblock.12830/
FakeBlock
This versatile plugin allows you to create fake blocks that exist for some players and do not exist for others!
These fake blocks are indistinguishable from real blocks and prevent players from walking through them, or interacting with them.
.addPacketListener(new PacketAdapter(main, ListenerPriority.HIGHEST,
PacketType.Play.Server.BLOCK_CHANGE) {
@Override
public void onPacketSending(PacketEvent event) {
if (event.getPacketType() == PacketType.Play.Server.BLOCK_CHANGE) {
Player p = event.getPlayer();
PacketContainer packet = event.getPacket();
event.setCancelled(true);
}
}
});``` does not work
what does not work
the door was opened
there may be a collision event
I can't find anything looking under org.bukkit.event.entity or org.bukkit.event.player
hmm oh well
i need help iam trying remove items when player die , only the items with [Kit Lore]
but its not remove them ..
idk what's wrong there ar eno errors in the console
@twin venture use delayes task after respown
this is in playerDeathEvent ..
i really need help i was trying to figure this out for like 5 hours now ..
Set it null
that won't work
I would use pdc rather than lore
Well then iterate thru slots
what do you mean?
?pdc
@twin venture just iterate per slot
And set item to null
Check for lore
best answer ..
Dont set item material to null
I told u to iterate thru inventory per slot
ok
And then u grab current slot number set it null and done
still learning don't be mad bro .
It is ok np
What's the best way to store a player's Location as a primitive type? My first thought is an int[] with {x, y, z}, but that misses out world, and looking direction. I could have multiple primitive vars where one is {x, y, z}, then {pitch, roll, yaw}, then ẁorld_index but there might be a better way...
Store where?
You've probably seen the /spectator mode thing for smp before, where running the command toggles you between spectator and survival, but going into survival puts you back where you went in to spectator, so you can't use it for teleport as such, I'm making a simple implementation of that, except you need to store the last location persistently
thanks!
I didn't quite get my head around the to primitive and from primitive
a container that persists data
Stores data on an object that is saved with the object
for example, a custom ID on an itemstack that lets you identify it as a custom item easily
without having to check for visible and modifiable things like lore or name
and allows items to be renamed and their lore modified
Is it supported on 1.8
obviously not
no
nothing is supported on 1.8
tell those people to piss off
tell choco to delete them
@wraith rapids is that possible
of course
If some one review base on version
if its a dumb or false review you can yeet it
reviewing something poorly because it doesn't work on a version it's not intended for is a false review
Didn't know that and 1.8 and older version are making my plugin big and problematic
just drop 1.8. If they want 1.8 they use older versions.
Supporting 1.12 or older means that you cannot make any use of the wonders of newer java versions - which is another thing to consider
Wait, what are you supposed to pass as a type for the second argument of PersistentDatContainer#set - PersistentDataType<T,Z> type?
I was thinking PersistentDataType_LOCATION.class or something, although that doesn't work
if you are using the class I just gave you, you pass it
intellij doesn't like it
if it wanted a .class, the method declaration would say it wanted a Class<PersistentDataType<T,Z>>
IJ or javac?
yeah, you are trying to provide it a Class
it doesn't want a class
it wants a PersistentDataType object
yeah, no .class ^
yeah, I'm not sure what to pass 😳
Don;t worry, when I came back to Bukkit a couple of years ago I fell over that too
Look how the PersistentDataType is implemented in the interface itself
on the paper discord I think
I could not for the life of me see what I was doing wrong.
it was quite amusing
Yep, it was on paper and NNY was my saving Angel
no the thing is, I swear I tried that, and it just didn't work, hmmm
I have no idea what I did lol
No because you did it wrong
everybody else was telling you to learn java
Yeps
How I can apply change without send packet to players? java Sign sign = (Sign) new Location(Utils.world, x, 23, z).getBlock().getState(); sign.setLine(2,"");
you drop the packet with protocollib or you use nms to skip the doodads that send the packet
so i found this code in the fourm .. its working for me thx for the guy who make it
it fixed my problem ..
but my other problem is not fixed
i gived my self diamond
and when i died well diamond is stuck with me
..
well i guess i need to get the last location of player before respawn?
how to make game?
a fucking brilliant question
What game?
you shoot it dead and you've got game
@wraith rapids so was looking in to pdc
Will this not be more complicated or intense on system then just using nbtapi
ItemStack itemStack = ...;
NamespacedKey key = new NamespacedKey(pluginInstance, "our-custom-key");
ItemMeta itemMeta = itemStack.getItemMeta();
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
if(container.has(key , PersistentDataType.DOUBLE)) {
double foundValue = container.get(key, PersistentDataType.DOUBLE);
}
no
@eternal oxide u sure
PDC is a wrapper over NBT
its doing the exact same thing as NBTAPI
@ivory sleet nbtapi then pdc
I asked what is simpler. Not which one.
Myeah in that sense I guess
Like here u need instance of plugin to get namespacekey
And so on
So I dont know which will be more intense on plugin
Example nbtapi can do lag if u are checking nbt data on pickupevent
And there is lots of items
Expirianced it
Learned on hard way xd
🌞
hi guys i am making a kitpvp plugin for my server, tho i have like 20kits or something, and i want to "register" them efficiently, how would i do this, i got an abstract class ( i know i can make it an interface but i tought i could add something in it)
as u can see many lines in the archer class are taken by getting itemstacks
For the registration, maybe have some sort of immutable registry and then have a builder, each entry would take 1-2 lines.
yeah, as of registering i know how i could make, the only thing is how i would actually make the kit class compact
wither skull is its own block these days i'm pretty sure
Cuz MrTommy was taken lol
If you're going to make all methods abstract, you'd rather use an interface for it lmao
thats what i said, its because i think i will place a full body method there
thats why i made it abstract
Btw, there are so many methods that are not actually needed to be abstract. You can simply make a super class wich requires a list of the items and the permission needed for this kit, that way you can define the kits and not even need to make a subclass extending from Kit
yeah i know, but i feel better using interfaces and abstract classes
Smth like:
public class Kit {
private List<ItemStack> items;
private String permission;
public Kit(List<ItemStack> items, String permission) {
this.items = items;
this.permission = permission;
}
//Just make the getters
}
Well, it's not
as you see, you're complicating so much trying to make it that way ;p
the only thing, if i make an itemstack of potions with amount for example 27 and i give them to the player, will they stack or not?
also, what is the sound that the arrow makes when hitting the player?
https://youtu.be/QWhfpniYV3w this one
They will stack
sad
mye
Just add each one individually
For loop go brrrrrr
if you know
still, linkedlist would be used
ArrayList iterates faster probably tho
Copy this, I think this might be helpful:
public void addVanilla(Player target, ItemStack item) {
int iterations = item.getAmount() / item.getMaxStackSize();
int toGive = item.getAmount();
for (int i = 0; i < iterations; i++) {
int give = toGive % item.getMaxStackSize();
toGive =- give;
ItemStack itemToGive = item.clone();
itemToGive.setAmount(give);
target.getInventory().addItem(itemToGive);
}
}
Or just an array
@kind coral, you might want to take a look to this snippet
I'm very curious if we have a class that extends ItemStack, say PaperClone that is basically of material paper, without extra stuff like display name or custom model
Can the server recognize that the item is an instanceof PaperClone?
an object on the server, yes. An ItemStack sent from the client, no.
But you can mix this paper with other normal paper, no?
I mean ItemStack is just an api class essentially
Extending it will have minimal impact though as it for instance gets cloned to a CraftItemStack or the nms variant depending what you do with it
Only when in runtime, when the item gets serialized and retrieved back (e.g. Server Restart) server won't be able to recognize it anymore
or i could just check if the itemstack is a potion and do a for loop
or just check if the itemstack is above max stack size
Oh yeah that’s true unless you’d annotate it with the configuration serialization delegation annotation I think?
Method is meant to work globaly for any item you want
Not only potions
i just need potions so yeahh
that's exactly what the method does
lol
anyone knows btw?
yeah
Check Javadoc
i can't find it
i saw arrow hit player and arrow hit
they do not match
Oh, yes, you can override that ;0
How I've been so stupid this time
I found out about it recently also 😅
Ohhhhh
Right
More practical than make it a mixin using a custom Java Agent kek
🥲
the underlying server itself doesn't handle ItemStacks at all
ItemStack is a bukkit api concept
every time you pass an ItemStack to the server, for example by placing it in an inventory, the values of the ItemStack are retrieved with the various getters and a new nms itemstack is built from them
yea that makes sense
kinda, but you can override those getters to make that items custom ;p
well yes, but only within the scope of those getters
Like a getLore, you can, for example, make the lore prettier using a better design for enchantment definitions
just to give you an example
and when you retrieve it back from the inventory or wherever you placed it, you will just get a new standard CraftItemStack instead of your custom class
you can do it, but you need to remember that the moment you pass your item to the server it drops everything except what an itemstack might be expected to hold
Basically ^^
there is some issue with my mob spawning in my world .I don't know why the chest become invisible but I can open them
They seem completely unrelated…?
mob spawning? chest invisible?
sounds like a 1.8 user
i was wondering about this cuz we discussed about testing if an inventoryholder is an instanceof a custom class that implements inventoryholder
which I also find weird that it is possible
that every of this instance in saved in metadata space?
ItemStacks get cloned like whenever u pass them through other api classes
InventoHolder is quite different sometimes
Bukkit is stupid when it comes to implement your own version of their api stuff lol
keep that in mind
inventoryholder can hold classes provided by plugins as it is not persistent
Yeah it misses @NonExtendable 😫
it only exists as long as the inventory itself is around
i'm not sure if it is evicted properly on plugin unload
probably not
Reload the inventory holder somehow (Reloading a chunk if its a Chest or Player Rejoin if it's a player) and will most likely go brrrrrrrr
i still can't find it, anyone knows?
Sound.ENTITY_ARROW_HIT_PLAYER?
and that's why you need to provide a PersistentDataType both when setting and getting from a PDC
its different
neither the complex object nor the data type object are stored anywhere at all
only the primitive data the datatype's serializer shits out is stored
Probably just different yaw and pitch
so, sounds have yaw? kekkkkk
You can always serialize a Function (don't.)
Yeah I believe lol
nop, i've tried everything ahah
Assumably not
naw, they don't
probably client sided
even if you do try to serialize the function, the function object itself is not retained anywhere
maybe Sound.ENTITY_ARROW_HIT?
Oh nvm volume 🥴
nop
prob client side then, only heard by the shooter
bruh
or player level up one
But what solarrabbit mentioned is correct for vanilla
nono i mean the minecraft one, btw i fixed it i made a for loop that plays each pitch from 0 to like 2 and it was 0.5 thx 😄 i tried them all by hand but i think i missed 0.5
👍
What's the best way to go about making a http request in a plugin?
That all depends on what request you want to make and what to do with the response
POST request & the response is pretty much not needed (except status like 404)
this is a simple request. just wrap it in an async task ```java
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
URLConnection conn = url.openConnection();
conn.setReadTimeout(5000);
conn.addRequestProperty("User-Agent", "Mozilla/4.0");
conn.setDoOutput(false);
// Handle redirects.
String redirect = conn.getHeaderField("Location");
if (redirect != null){
conn = new URL(redirect).openConnection();
}```
as you don;t need to know what the response is
wouldn't that make a GET request?
if only java 16 had an inbuild http client
else, a very quick google returned https://stackoverflow.com/questions/3324717/sending-http-post-request-in-java
Perfect, thanks!
or just use the http client xD https://openjdk.java.net/groups/net/httpclient/intro.html
might be the more elegant solution anyway
Does anyone have an idea to create a collision system that can rotate the item through the place it collided?
is hard to explain
this is minecraft dude, not a game engine
take it or leave it kek
your bastard, even if it's minecraft regardless or there are no ways to do this
define 'item'
armor stand euler angle
not like, I managed to do similar things by rotating the item across the face of the block
hm
if you plug into nms for collision shapes or hardcode them yourself, yes
after that it's just math
after that it's just math
like, i use a egg like projectile
I mean, he refered to rotate an entity through the place it collided
basically implement physics
I use the projectile to detect collisions, but the tricky thing would be to just rotate it according to the direction the projectile went, but there are certain times when it rotates the item gets into the block xd
that's the thing
I think there is no conventional way to do this
to not say there is no way to do this cuz I'm not totally sure tbh
implementing physics is just math
and something that has been done a billion times, so a lot of helpful resources exist for it out there
i do not know how to do it
look it up on stack overflow
i check
check again
i'll check***
but, again, you need access to collision shapes to rotate things properly
otherwise it'll phase into shit while you rotate it
i cant use the euler angle like a collision shape ?
rotating a collision shape causes its points to move
if you rotate your item, you move the points of its collision shape
you need to be able to tell when those points collide with other collision shapes and stop rotating it accordingly
otherwise the corners of your item will phase into shit while rotating
well. unless your collision shape is a sphere
Is there a way to register/dispatch events? Not listeners, events.
Bukkit.getPluginManager().callEvent(event)
Yes, but you should only ever do it to offer other plugin the opportunity to prevent your actions
I want other plugins to be able to hook into my plugin
for 'registration', your event class should declare a public static HandlerList getHandlerList() method which should return the class' HandlerList
f.e
public class TransactionEvent extends Event {
private static final HandlerList handlers = new HandlerList();
@Override public @NotNull HandlerList getHandlers() { return handlers; }
public static @NotNull HandlerList getHandlerList() { return handlers; }
java can't enforce you to implement a static method, so the most common noob issue with custom events is forgetting about the static getHandlerList
is PluginManager.callEvent() blocking?
yes
hmm ok
It has to be so you can get teh canceled state when finished
cancelled state?
If your event is cancelable .
ah
it gets passed to any registered listeners, then you get it back to see if anyone made any changes
so
I would construct the event with whatever parameters that I want, and then call it, correct?
yes
the return of callEvent gives you the result of your event
its void
chaining .isCancelled on it would be too easy
should i call super() in my constructor
super is called implicitly
Event has two constructors
the default no-args constructor
and a constructor intended for events that are supposed to be fired asynchronously
which lets you pass a boolean that determines whether the event is fired asynchronously or not
if it returns void how do I get the result
you store the event in a variable
the event you pased
PreTransactionEvent preEvent = new PreTransactionEvent(... );
Bukkit.getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled()) { do stuff }
there is no explicit, separate result; the event instance itself is modified
That event is not cacnelable
how do I listen to an event i dispatch
as you would to any other event
same as you would any event, import it in a Listener
how does bukkit know which listeners to fire when an event is dispatched, is it the name of the listener or something else
wrong question mb
how does bukkit know which event to register the listener to
is it the name of the listener or something else
registerEvents scans the class of the object you pass it
and looks at the method declarations
ohhh so its the type of the argument
yes
wow i was overthinking that
can I ask a ruby question here
only if it's ruby on rails
# event.start_date = 2021-06-25T00:00:00.000Z
clone = event.clone
clone.attributes ={:start_date=>event.start_date.strftime("%d %B %Y")}
render json: {:start_date=>clone.start_date, # = '2021-06-25T00:00:00.000Z'
:intended_date=>event.start_date.strftime("%d %B %Y")} # = '25 June 2021'
ok it is, so basically
my clone's attributes never gets updated
any idea why
no
ok maybe now clearer
does it go all the way up the hierarchy ladder? like if I dispatch an event that extends another event and there is a listener that listens to the base event will it get fired when the event that extends the base event is dispatched
woah boy thats some run-on sentence
only events that have a static HandlerList in the class can be listened to
abstract superclasses like Event or PlayerEvent don't, so you can't listen to them
but yes, each superclass of an event declaring a HandlerList is invoked in order
for example, EntityDamageEvent and EntityDamageByEntity event both declare a HandlerList
firing the latter will first fire listeners for the latter, and then for the former
while firing the former only fires the listeners for the former
alright, makes sense
i see you used isCancelled, is that a method I have to implement myself or do I inherit from another class
you'll have to implement it yourself if your class extends/implements Cancellable
but, it's just a boolean field with a setter + getter so not much to implement
That's a hopper
Ahhh
Hey, I have a question, according to this wiki https://www.spigotmc.org/wiki/creating-a-gui-inventory/ I should create a variable outside of the functions and then use that variable in the "event" function InventoryClickEvent to check if the inventory is the same. Is there any other alternative to not creating a variable outside of the functions or do I have to do like the wiki?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
super hyper technically yes there is an alternative but it's not one you should take
using fields is part of java; you should get used to it
Ok so better to use the wiki technique
Sorry, not really sure where to ask this - I have had multiple users show me that there is no option to pay for my premium plugin when they click the purchase button on the resource page, I have had people purchase it already (last one was on the 25th of June) but nothing has changed on my end and now it seems that the option isn't there for new purchases. Any ideas what could have caused it or where I should take this problem?
Come join us socialists. Give us everything and we'll look after it for you.
How do I make it so when I type a command for example "/tp" and I go to type the next argument to show me a list of options like "/tp" does show a list of players
No clue xD try asking in the off topic/chat/help and try the irc, maybe they know there
Do you mean tab complete?
Yes, that's what I mean
Aaaah, I'm not at the pc atm, but if I remember correctly you have to implement it and populate a list or something along those lines
Do you know a tutorial or a post somewhere?
nvm, I found a tutorial when I searched tab complete
implement tabexecutor and return a list of results
thanks
how to force entity to shake?
a brilliant question
type in chat "boo" while looking at it
works better if the entity doesn't see you
ha-ha
Why is the tab completer not working?
Did you register the tab completer
Yes, like this "getCommand("privateChest").setTabCompleter(new VaultTabCompleter());"
Do you know why it doesn't work?
have you debugged it
no
try debugging it
probably
a good first step is to have sysout in your onTabComplete to see if it's getting called at all
It doesn't get called
how do i set a permission level for a command I am making?
Example: I want to req op or a custom permission to run a command.
if (!sender.hasPermission("myperm")) return;
if (!sender.isOp()) return;
Anyone knows why tab completer might not work?
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (!(sender instanceof Player)){
Bukkit.getServer().getConsoleSender().sendMessage("Tab Completer non player");
return null;}
Bukkit.getServer().getConsoleSender().sendMessage("Tab Completer");
List<String> arguments = new ArrayList<>();
arguments.add("Argument1");
arguments.add("Argument2");
arguments.add("Argument3");
return arguments;
}```
getCommand("privateChest").setTabCompleter(new VaultCommand());
I watched a couple tutorials to figure what I did wrong but they did same thing as me
it seems fine to me hmmm
