#help-development
1 messages · Page 1652 of 1
then remove all recipients
Cancelling the event will work.
either or
put your test before you remove the entry
ye
@EventHandler
public void onChat(final AsyncPlayerChatEvent event) {
final String message = event.getMessage();
if(this.waitingInputMap.containsKey(event.getPlayer().getUniqueId()))
event.setCancelled(true);
Optional.ofNullable(this.waitingInputMap.remove(event.getPlayer().getUniqueId())).ifPresent(consumer -> consumer.accept(message));
}
like dis?
ok it works
Hello, I did some debug and my code to close a trapdoor doesn't work
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.
all my debug results are there after //
found some things on google to do it
how can i remove a plugin?
from your server ?
https://hastebin.com/ganutekenu.kotlin Hey, i have a Problem with getNearbyEntities in the 1.17. In the 1.16.5 it works. In the 1.17 the async catcher dont like it. Have anyone an idea?
???
Oh sry, i mean 1.15. Is there a way to fix that for the 1.17?
execute it on the main thread
I dont want to rewrite the class
you will have to
there is no way you will ever need to loop through entities asynvhronously
especially not in a range
report it
can someone please tell my why this ONLY works the first time??
public static void enableAutoSave() {
Bukkit.getWorlds().forEach(world -> {
// this only saves the chunks that haven't been blocked in the UnloadChunkEvent event
world.save();
// copy the seed and stuff from this world
WorldCreator worldCreator = new WorldCreator(world.getName());
worldCreator.copy(world);
// chunks that have been generated but blocked from being saved in the UnloadChunkEvent event are kept saved somewhere
// (God only knows where and why) so if we unload the world (with save = false), those chunks are lost, THAT'S WHAT WE WANT
Bukkit.getServer().unloadWorld(world, false);
// now load the world again
World reloadedWorld = worldCreator.createWorld();
reloadedWorld.setAutoSave(true);
});
}
the event just in case
@EventHandler
public static void onChunkUnload(ChunkUnloadEvent e) {
if (ChunksHandler.isUseless(e.getChunk()))
e.setSaveChunk(false);
}
maybe Bukkit.getWorlds() is storing the old references or something like that? i really dont know, but it works as expected the first time after each server restart
context: after generating a lot of chunks with autosave in off, i call enableAutoSave to enable it again, but without saving all those useless chunks (trying to)
what is a base world? and it could be any world in theory, but now im doing it with the end, not a new one, just the default one, world_the_end
World, the end and nether can not be unloaded
but now its working more than once, wtf, i only added comments
its hard coded to block unloading of those worlds
but its working, also i get this on console, maybe multiverse "unblocks" that?
[19:11:17 INFO]: [Multiverse-Core] World 'world_nether' was unloaded from Multiverse.
[19:11:18 INFO]: [Multiverse-Core] World 'world_the_end' was unloaded from Multiverse.
[19:11:20 INFO]: [Multiverse-Core] World 'test' was unloaded from Multiverse.
Multiverse says its unloading but its not
mmm
but im loosing those useless chunks, which is what i want, so, i guess its fine
it only picks up test on reloading
yeah
mmm
but its definitely doing something, bc im not getting a lot of useless mca files now
which is good
works for me
How do you properly check if a player right-clicks with a specific item in 1.16? I've looked all over the internet and can't seem to find anything that works, please help.
PlayerInteractEvent iirc
get the item in their hand
check that the action was a right click
Well, according to my checks, I seem to be struggling with checking the item, not the right-click. Here's what I have so far:
@EventHandler
public void selectMenu(PlayerInteractEvent e) {
Player player = e.getPlayer();
Action a = e.getAction();
if(a.equals(Action.RIGHT_CLICK_AIR) || a.equals(Action.RIGHT_CLICK_BLOCK)) {
player.sendMessage("Check One : Passed");
if(e.getItem() == ItemManager.fireToken) {
player.sendMessage("Check Two : Passed");
SelectionScreen gui = new SelectionScreen();
player.openInventory(gui.getInventory());
}
}
}
}```
*check one fires every test but not check two
== for comparing enums, .equals for comparing objects
I tried both, neither work
getItem().isSimilar(ItemManager.fireToken)
If not null
you could reverse it to avoid a null check
if (ItemManager.fireToken.isSimilar(e.getItem())
I personally would always go for PDC for cusom item identification.
Ooh, it works, thanks! You have NO idea how long I've been trying to figure this out for
What's PDC?
?pdc
Thanks, I'll check it out! For now though, I'm just happy that what I have works
how can i get all online players on bungee?
Google your question before asking it:
https://www.google.com/
bump
You're not doing it correctly
You need to update the BlockData of the state first
Or just do it directly without BlockState
TrapDoor trapdoor = (TrapDoor) block.getBlockData();
trapdoor.setOpen(false);
block.setBlockData(trapdoor);```
thanks, but that function does not seem to exist for Block
ok found it, thanks I'll try that : )
Hello! where are players data saved?
I see usercache there, but idk about exactly playerdata
but it contains a bit information about player
uuid, name, expire date
idk what expire date mean too
guys
how do u
put like
a 1.8 plugin and a 1.17 plugin in
together
and then when put on server
it uses the one for that version
i never done
i stupid
They use wrapper
The developers create that method by themselves
Can say it is a trick
i always gotta change shit
When any version possible, wrapper will wrap that version, use that version and leave others.
You have pretty much two options. 1) Make an implementation for each version. Or 2) start with the 1.8 api and write all the methods modified/removed/added by yourself
while making sure they are compatible with the current whatever api you use
The latter is easier
Hello, I have been trying to figure out a way to save a villagers nbt data inside an item's PersistentDataContainer, but it gives me an error every time. What is the most efficient way of getting around this?
I tried researching this issue, however I couldn't find anything.
Hello, trying to make it so that spawners in the nether don't drop (you break them but nothing happens). Here's my code:
@EventHandler
public void onBlockItemDrop(BlockDropItemEvent e) {
if(e.getBlock().getWorld().getName().equalsIgnoreCase("world_nether")) {
if(e.getBlockState().getBlockData().getMaterial().toString().equalsIgnoreCase("SPAWNER")) {
e.getItems().clear;
e.getPlayer().sendMessage(ChatColor.RED + "Spawner breaking is disabled in the Nether!");
}
}
}
Everything works except the e.getItems().clear;, but I couldn't find anything else to clear the drops. Any ideas?
can i add tags or metadata to placed blocks somehow? i want, if a player right clicks a certain copper slab, to get an item. but no other copper slabs, only this one
is there some way to uniquely identify this one block over all of the other types of that block?
Is it only ever going to be one of them at a time?
If so you could store the location in config or something
three
Just store them in config
still doesn't work
b.getState().setData(door);
b.getState().update();```
Hey for BungeeCord can I have it connect to a fabric, forge, and java server at the same time
neither Block#getBlockData() nor Block#setBlockData() in 1.12
@waxen plinth
What are some other options for Bukkit.dispatchCommand(executor, command);the executor, I know I can use getConsoleSender, but it spams the console
Why are you in 1.12 🙃
b.getState().update() will literally never do anything
someone suggested to do update(true)
You want to do this without feedback?
That won't work either
Yep
Because b.getState() returns a fresh BlockState
You need to keep that instance
Call your methods on it to mutate it
And then call update on that BlockState instance
okay thanks
To my knowledge there is only one way to do this and it is extremely hacky
Basically only works because CommandSender is an interface
i lost my patience trying to prevent chunks from being saved to disk. sometimes it works and sometimes it doesnt, and i dont know why. i think i will go back to the deleting mca files directly method. how slow/cpu intensive is the World#isChunkGenerated method? i mean, what does this method do internally? just checking arrays? is it feasible to save a set of all the chunks that are generated in a world? (obviously only x and y, not the whole chunk object)
It's fast
I don't know the exact implementation but I do know that it's rather fast
You can create a proxy class at runtime which implements CommandSender and forwards all calls to the console command sender
Except for the sendMessage, method, which is ignored
I mean I suppose you don't need proxy classes for this but they make it much easier
CommandSender console = Bukkit.getConsoleSender();
CommandSender fakeConsole = (CommandSender) Proxy.newProxyInstance(CommandSender.class.getClassLoader(), new Class<?>[] {CommandSender.class}, (proxy, method, args) -> {
if (method.getName().equals("sendMessage")) {
return;
}
return method.invoke(console, args);
});
// You can now use fakeConsole to execute commands which it won't receive feedback for```
any idea how to directly edit a mca region file? i mean, im not trying to paste a schematic or something like that, i just want to delete a whole chunk, it should be relatively simple, if its documented somewhere
yea i know, messing with bytes is not simple, but maybe someone here has some experience with that
Alright I’ll try and work it out, I had seen a BlockCommandSender would that work?
Huh
Just use that
Otherwise you'd need to place an actual command block and send a command from it
Which might not even work if command blocks are disabled
Sorry I meant would you know how to use that
No
But I think creating a proxy instance is the simplest way
It's hacky but it's simple and it works
Ok
I tried that
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.
is there still a problem with it cause it still doesn't work
You shouldn't be using BukkitRunnable, first of all
Second of all, add debug print statements to make sure your code is actually being run
Third, call update(true, false)
bump 😄
u did .equalsIgnoreCase("SPAWNER") when it should be spawner
i think
i think thats the problem
oh wait im stupid
got it mixed up with to lower case mb
e.getPlayer.getInventory().removeItem(e.getBlockState().getBlockData().getMaterial());
i think
just use e.getPlayer.getInventory().removeItem();
what if he doesnt pick it up
man my brain cells
is there really no method for removing a block drop?
are not working today
no there probably is im just dum
maybe try clear()? or remove()?
All that does is cancel the block breaking
Oh, what if I cancel the event and then remove the block
its on blockdrop
not block break
ohh right
this is equally valid tho
Hey just quick question how do i check if the player head is under the water
.getLocation() returns the position of the player's feet so how do i add 1 to the Y axiss
ty
maybe someone can help me with this multicraft installation! I have setup DB's multicraft_panel, and multicraft_daemon and initilized the database, and everything went good, and then went to startup my daemon, and refresh the list on the web install, and it doesn't show my daemon on the list? I made it 127.0.0.1, and setup my user, and password, etc.
how do i load an Inventory from config?
Might be a stupid question here, but what am I not getting here? I want to accomplish the last line, but it just doesn't work. Both a string and string[] should work as arguments. The IDE help doesn't help much either..
https://gyazo.com/716e3bbc889c16969703edc687cd0350
https://gyazo.com/e2983a929206c8d6c39fd13f21000183
Ah, it worked if I did the boolean check before initializing the array
Hi, will PlayerDeathEvent be dispatched if the player used an undying totem?
I wouldn’t imagine so as there is an event for that
What should I do if I want to damage a player and change the death cause if the player died
mob.setTarget(Player)
What do you mean cause?
set tatrget nio work
If I compile my plugin with Java 1.8, would it still be able to run on a 1.17 server? Seems that an API I'd like to use not supports Java 16 yet
?paste
hey, please help
here is my code: https://paste.md-5.net/pepusefihi.java
when i run it with commented code it causes this error: https://paste.md-5.net/wujosowozu.cs
when without it no errors but spawns only 1 armor stand instead of two and in wrong location (in console location are valid)
edit: same code works fine in other projects
Use OfflinePlayers cause lag?
ok thx
Yes
well it depends on what data you have in the config
My maven project suddenly moved my java folder to the package so lots of imports are wrong, not sure why this happened. Any idea what the best way to solve it without making any damage to the project files would be?
https://gyazo.com/57df645ec3a84de06b07974c4e0783d3
This is how it used to look like with the java folder
https://gyazo.com/99c1aa08e8270626f79ba09d7c8fc35e
my warps.yml file isnt getting created
private File warps;
private YamlConfiguration modifyWarpsFile;
private static Main instance;
@Override
public void onEnable() {
// STARTUP MESSAGE
System.out.println("<<-------------->>");
System.out.println("QuagWarps Enabled!"); //shortcut -> sout tab
System.out.println("<<-------------->>");
// INSTANCE
instance = this;
// CONFIG
this.getConfig().options().copyDefaults();
saveDefaultConfig();
// COMMANDS
getCommand("setwarp").setExecutor(new SetWarpCommand());
getCommand("delwarp").setExecutor(new DeleteWarpCommand());
// INITIATE FILES ON START
try {
InitiateFiles();
} catch (IOException e) {
e.printStackTrace();
}
// CREATE FILE LOCATIONS ON START
if (!getWarpsFile().isSet("warps")){
getWarpsFile().createSection("warps");
SaveWarpsFile();
}
}
@Override
public void onDisable() {
System.out.println("<<-------------->>");
System.out.println("QuagWarps Disabled!"); //shortcut -> sout tab
System.out.println("<<-------------->>");
}
// MODIFY WARPS FILE
public YamlConfiguration getWarpsFile() {
return modifyWarpsFile;
}
// GET WARPS FILE
public File getFile() {
return warps;
}
// SAVE BANK FILE
public void SaveWarpsFile() {
try {
modifyWarpsFile.save(new File(this.getDataFolder(), "warps.yml"));
modifyWarpsFile.save(warps);
} catch (IOException e) {
e.printStackTrace();
}
}
// INITIATE FILES
public void InitiateFiles() throws IOException {
warps = new File(this.getDataFolder(), "warps.yml");
if (!warps.exists()) {
warps.createNewFile();
}
modifyWarpsFile = YamlConfiguration.loadConfiguration(warps);
}
// INSTANCE
public static Main getInstance() {
return instance;
}
That didn't change anything, thanks though. I think it's related to some change I might have made in the pom recently
If the dataFolder isn't created it will cause an error on createNewFile()
there is a datafolder
Found out what it was
Why are you create a new instance of the warps file?
modifyWarpsFile.save(new File(this.getDataFolder(), "warps.yml"));
modifyWarpsFile.save(warps);
so i can access it from other classes
nvm
wait where is that?
public void SaveWarpsFile() {
oh so i should do it like this?
can hackers access the config.yml file?
Its cleaner and uses the object you already variablized
okay
Depends....
on what
If they access your servers files then yes. But just from joining your MC server.... Highly unlikely.
oh alr
thx
nobody should have access if the server is just on my pc right
when theyre joining remotely
But if you have editor plugins on your server and they gain op perms then yes.
so i updated this to my current Main.java, and it still doesnt create the file
Because you now have both
modifyWarpsFile.save(new File(this.getDataFolder(), "warps.yml"));
modifyWarpsFile.save(warps);
``` You only need `modifyWarpsFile.save(warps);`
oh
new File(this.getDataFolder(), "warps.yml") creates a new instance
help
now
what to do instea dof service manager in bungeecord
never done bunghee befpre
okay
still nothing...
?paste your updated code
yes?
Debug it make sure the methods are running
?jd
i dont thing there are service providers in the bungee API
i enabled my plugin but still nothing got send
private File warps;
private YamlConfiguration modifyWarpsFile;
private static Main instance;
@Override
public void onEnable() {
// STARTUP MESSAGE
System.out.println("<<-------------->>");
System.out.println("QuagWarps Enabled!"); //shortcut -> sout tab
System.out.println("<<-------------->>");
// INSTANCE
instance = this;
// CONFIG
this.getConfig().options().copyDefaults();
saveDefaultConfig();
// COMMANDS
getCommand("setwarp").setExecutor(new SetWarpCommand());
getCommand("delwarp").setExecutor(new DeleteWarpCommand());
// INITIATE FILES ON START
try {
InitiateFiles();
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "msg kipteam Initiating Files");
} catch (IOException e) {
e.printStackTrace();
}
// CREATE FILE LOCATIONS ON START
if (!getWarpsFile().isSet("warps")){
getWarpsFile().createSection("warps");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "msg kipteam setting warps section");
SaveWarpsFile();
}
}
@Override
public void onDisable() {
System.out.println("<<-------------->>");
System.out.println("QuagWarps Disabled!"); //shortcut -> sout tab
System.out.println("<<-------------->>");
}
// MODIFY WARPS FILE
public YamlConfiguration getWarpsFile() {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "msg kipteam get warps file");
return modifyWarpsFile;
}
// GET WARPS FILE
public File getFile() {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "msg kipteam get File");
return warps;
}
// SAVE BANK FILE
public void SaveWarpsFile() {
try {
modifyWarpsFile.save(warps);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "msg kipteam save warps File");
} catch (IOException e) {
e.printStackTrace();
}
}
// INITIATE FILES
public void InitiateFiles() throws IOException {
warps = new File(this.getDataFolder(), "warps.yml");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "msg kipteam setting warps File");
if (!warps.exists()) {
warps.createNewFile();
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "msg kipteam creating new warp File");
}
modifyWarpsFile = YamlConfiguration.loadConfiguration(warps);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "msg kipteam making modifications possible");
}
// INSTANCE
public static Main getInstance() {
return instance;
}
Dont use plugman and dont use reloads.
oh?
Please tell me you aren't reloading your plugin using /reload or plugman
It doesn't load new code.
nah i have restarted my server plenty of times now
They will break stuff.
What exactly isnt working?
my file isnt getting created
Is it not being created or just not being written to?
created
Ok lets see
Are you sure its not erroring on enable?
So the normal config.yml is not saved?
i dont know tbh i am not using that one
Then why do you call saveDefaultConfig() then?
This conversation is just making me laugh a bit lol
i just made the config to get the datafolder
and i wanted to use it later on
if you're not using config.yml and instead a custom one, look up the wiki for thay
Ah i see. Btw the data folder can be obtained by calling Plugin#getDataFolder()
cant u just doplugin.getDataFolder
^^
how do i obtain the data folder?
sorry
Plugin.getDataFolder()
Before we continue. Pls do not use dispatchCommand as logger.
Replace them with this.getLogget().info(String);
Plugin asin actually Plugin.getDataFolder() because that errors
Pls add a logging message at the start of your InitiateFiles() method and tell us if it gets logged.
that would have been temporary anyways
Nope the right notation is Plugin#getDataFolder()
So you need to call it from an instance of Plugin.
You can do that in your main class by this.getDataFolder(). But i see that you use it already.
that is what i did
Bad habits die hard
okay
Pls add a logging message at the start of your InitiateFiles() method and tell us if it gets logged.
"Cannot resolve method 'getLogget' in 'Main'"
getLogger()
So I literally copied the CraftServer.createWorld(WorldCreator creator) method yet when I use my own...
There is always something wrong... It can lag out the server, it won't teleport me, It will stay on "Loading terrain..." etc.... I just never not have issues with this method... Any ideas why?
WorldLoader.get().createWorld(new WorldCreator("TestWorld"));
And you made sure to not teleport to the world right away?
Yeah and teleport to the spawn chunks lol
Wait. You copied the method from CraftServer? Why.
I copied the method exactly this time to.
Because thats the method that actually creates the world
Yes. But why dont you just call Bukkit.createWorld() ?
Because I wanted to modify the method... But I can't even get it to work when I literally just copied and pasted it.
And actually this time... I can teleport to the world but can't move or placeblocks or anything
but i can run commands, chat etc...
But how do you access all the CraftServer fields from your copied method?
Console is just DedicatedServer which is retrieved by using console = console != null ? console : ((CraftServer) Bukkit.getServer()).getServer();
And the worlds map is just that lol... Map<String, World>
I was more looking at the Map<String, World>
Yes but do you actually use the Map instance that is inside the CraftServer singleton?
No because the worlds in this class aren't being created by CraftServer
private DedicatedServer console;
private Map<String, World> worlds = new HashMap<>();
public World getWorld(String name) {
if(worlds.containsKey(name))
return worlds.get(name);
return null;
}
-.-
Then at least try calling CraftServer#addWorld(World) after you created the world.
I'm not using the bukkit methods to get the world addWorld adds to the CraftServer map
Yes. And you dont know if this map is accessed and used by other classes that rely on every loaded world being present there.
Call CraftServer#addWorld(World) after you are done creating the world and see if that fixes your issues.
Do you add it to that map already?
Or do you add it to a random map you created for yourself?
Actually... there is no add in that method. Let me add one xD
Does anyone know of a plugin that scales health
so lets say you have 60 max health, and you are on 30/60 health, it displays your heart bar as 5/10
#help-server
This is for development related questions. What version are you on?
fam
wtfrick u saying
that's normal spigot?
No maxHealth is 20. He wants to set MaxHealth above 20 and count down hearts in the percentage of the maxHealth. Also hes looking for an already created plugin not the code for one.
Oh when was that added? But he still wants an already created plugin
...
I may have written and send it to him already
that's assuming the thing will work
if it was you i dont even mind lmao
but they could've done it themselves in a few minutes
Its literally just this
public final class ScaleHealth extends JavaPlugin implements Listener {
private double maxHealth = 20;
private double healthScale = 20;
@Override
public void onEnable() {
saveDefaultConfig();
reloadConfig();
FileConfiguration configuration = getConfig();
maxHealth = configuration.getDouble("PlayerHealth", 20);
healthScale = configuration.getDouble("HealthDisplay", 20);
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
AttributeInstance instance = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (instance.getBaseValue() != maxHealth) {
instance.setBaseValue(maxHealth);
}
player.setHealthScale(healthScale);
player.setHealthScaled(true);
}
}
true
no that's better than what he asked for
https://github.com/2Hex/Warps anyone wanna help me
find spaghetti code
I see you only have one ChatEvent instance now.
yes
gui.getItem(53) may return null if no ItemStack is in this slot.
but
im setting the item to not be null
if (gui.getItem(53).getType() != Material.ARROW)
gui.setItem(53, next());
}
then your code is wrong.
w h a t
lol, you are testing it before you set it
ah right
gui.setItem(53, next());
if (gui.getItem(53).getType() != Material.ARROW)
gui.setItem(53, next());
}
LOL
mgiht as well just remove the checl
or wait
i need it
ok lemme test
p.setPlayerListName();
exists but is there a way to apply it to an
EntityPlayer
a fake one to be more clear
Hi im Proffesional Fullstack dev, is there anything i have to know about spigot ?
Know Java
ye
You should find all the basic setups with dependency managers and your fav IDE here:
https://www.spigotmc.org/wiki/spigot-plugin-development/
Also if you use IntelliJ i highly recommend the mcdev plugin.
The API documentation can be found here:
?jd
I mean, if you're a web dev, knowing how to use spigot API won't be very useful for your job
But if you wanna make things with it ^
I want to write 4fun ingame/online shop
for friend server 😄 then im gonna upload api
The main thing you need to know is that spigot plugins are bootstrapped. Your entry point is a class that extends JavaPlugin.
But this should all be covered on the page ive sent you.
InventoryFramework is pretty good
Visualisation of shops can be done using several approaches.
Using an Inventory is one of them. Then there are chests with holograms above them which
provide the buyer/seller with information. ItemFrames are also possible.
Inventories just scale really well as the dont need any physical space.
I personally dont think that they are ugly.
. someone help plz ? :c
lets you import an inventory from xml files
You could use map rendering to have custom UI's but that would be a nightmare
The map idea is cool
maps in itemframes is doable, but its extremely advanced.
Look into CraftPlayer. I believe that there is no NMS method and you need to send packets to your players.
I want to make sth unique to make everyone use it, mainly im gonna focus on web store with control panel where u cant create your own ingame shops
the problem is that max char is 16
but with that method it becomes limitless
I've not used this library but it seems to be very comprehensive https://github.com/JohnnyJayJay/spigot-maps
If the limit is hard coded client side then you wont be able to exceed it. Worst case is a crashed client.
Och so I can upload my own img to map texture then I can make clickable points depends on x,y vector cords ye ?
how do i make it so there can be multiple pages for my gui, that's my try here:
for (String childSection : section.getKeys(false)) {
if (i == 54) {
i++;
continue;
}
ItemStack item = new ItemStack(Material.PAPER, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.YELLOW + childSection);
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GOLD + "Warp to: " + ChatColor.RED + childSection);
meta.setLore(lore);
item.setItemMeta(meta);
if(i >= 55){
getInventory().addItem(item);
getInventory().setItem(53, next());
i++;
continue;
}
gui.addItem(item);
if (gui.getItem(53).getType() != Material.ARROW)
gui.setItem(53, next());
i++;
}```
my problem is
it's not adding the items to the 2nd gui (getInventory)
ill rename it once it's working btw
because you hardcode the index at 53?
Also I believe that the player's inventory has less than 53 indexes, but I'm not too sure

there is no method that creates an explosion without the particles right? I have to make my own for that right?
53 will probably be some random magic inventory slot
wdym
What even is getInventory()
cancel the packet
no you did not
It'S the second inventory, but I do not know if it is a clone or something else
yeah I will have to do something, I just wanted to know if there was some createSilentExplosion() method or something.
1s lemme show u the whole code
@quiet ice
Map<Integer, Inventory> pages = new HashMap<>;
int count = 0;
for (String childSection : section.getKeys(false)) {
int page = count/53;
int slot = (54*pages.size())-count;
// Create inventory and add inventory to map or get inventory from map
// set item
count++;
}
```Something like this
it's a clone
You are creating 1 inventory for every itemstack
Everytime you call getInventory() it returns a new inventory
can u explain the math
im lazy
do you know a solution for that
Wouldn't a count%53 be faster and easier to read than the 54*pages.size()?
Just cache the return value of the method
wdym'
And you could likely make use of List<Inventory> instead of Map<Integer, Inventory>
I can barely explain it lol.
Basically the biggest inventory you can have is 54. So 0-53 is the slots. so the page number is gotten by the count divided by 53.
Slot is retrieved by getting the pages times 54 slots and then the count should be subtracted. Example if you have 3 pages thats 162 and if the count is 125 that would use slot number 37.
me shit at math
divide by 54. There are 54 slots on a page. They index from 0 to 53, but there are 54 slots
Same
why does everything need math
btw
can some1 help me
why is
the inventory getting cloned
public Inventory getInventory(){
Inventory gui2 = Bukkit.createInventory(null, 54, ChatColor.GREEN + "Warps: (Page 2)");
return gui2;
}
cache it
What do you mean by "cloned"?
you are creating a new one everytime getInventory is called
yes thats what i mean
only the name is identical
return Bukkit.createInventory(null, 54, ChatColor.GREEN + "Warps: (Page 2)");
is same thing right
idk why did i make a variable
but i need to access the inventory
from other classes
are you creating some kinda multi page gui system?
Is there a way to run console commands and getting command output back?
@grim ice i would create an abstract class called for example MultiPageGui and have everything cached in there
How do you think I felt when I made this...
https://i.imgur.com/BEQnkGC.mp4
I had to calculate the circles, The yaw to the center, the velocity etc...
then you can just make an implementation of that for your gui
that actualy looks really cool though
the thing is HOW
wtf bro thats so cool
i can show you a little example maybe let me see if i have it
yes
and not in a method
OH
what is the min and max of getHardness()? there is no info about it on the docs.
laggy client
I still had 300 fps 🤷
@grim ice
/**
* An advanced menu listing items with automatic page support
*
* @param <T> the item that each page consists of
*/
public abstract class MenuPaged<T> extends Menu
{
/**
* The pages by the page number, containing a list of items
*/
@Getter
private final Map<Integer, List<T>> pages;
/**
* The current page
*/
@Getter
private int currentPage = 1;
}
this is how i would go about it
very basic example of course
well yea
a map isnt really needed
Map<Integer, Inventory> pages = new HashMap<>();
int amount = section.getKeys(false).length();
int pageCount = amount/54;
for(int i=0; i <= pageCount; i++) {
pages.put(i, Bukkit.createInventory(/*You're code*/));
}
int increment = 0;
int currentPage = 1;
for (String childSection : section.getKeys(false)) {
Inventory i = pages.get(currentPage);
i.setItem(increment, ItemStack);
increment++;
if(increment > 53)
increment = 0;
}
```Here is a better visual of the code.
o
https://i.imgur.com/s8wGUcv.mp4 I made this awhile back to. (Back on the math BS lol) Having to set velocity of the player and falling blocks.
how do you get it so smooth
Math
i have bneen messing with this kinda stuff forever
never got it this smooth
yep i guess thats a good answer
Math huh :)
Lol one sec
It was made as an api that I release for sale. Never open sourced it though.
btw
getKeys is a set
u cant get the length of it
well u can by making it an array
do i do that
#size()
// Looping through all blocks and setting their velocity.
for(FallingBlock fb : movingBlocks.keySet()) {
Location loc = fb.getLocation(); loc.setPitch(-90f); Vector vec = loc.getDirection();
// Modifying the velocity and checking if the elevator should stop.
if(paramUp) {
if(fb == mFB && loc.getY() >= sl) {stopElevator = true;}
vec = loc.getDirection().add(new Vector(0, finalSpeed, 0));
}else {
if(fb == mFB && loc.getY() <= sl) {stopElevator = true;}
vec = loc.getDirection().add(new Vector(0, finalSpeed, 0));
}
fb.setVelocity(vec);
fb.getLocation().getBlock().setType(Material.AIR);
}
Yo short question. I want the player to teleport out of a chunk he is standing in. for example: he is stading on x: 2 / z: 3 (chunk locations) and I want him to teleport to x: 0 / z: 4 - but with normal world coordinates I am just not sure how to do it, cause I would need the distance from the current chunk position to the chunk border, so I can could teleport the player outside as much as he needs to be to.
My only idea would be to loop x and z back as long as a new chunk is coming, would be that the best solution for this problem?
actually isn't the most difficult math ive seen. but i woulve still never come up with it
really cool
Thats not even the speed math lol
Still not to difficult though
Honestly might remake this API and open source it
well i would enjoy looking through it and might even use it :D
Hello, i have got a problem with Residence plugin. It says An internall error occurred while apptempting to perform this command
Console says about the plugin is disabled..
Can someone help?
show us the full error
Ok
how to access inventories from other classes?
like, i made an inventory in a class i want to use it in another class
you just need a reference to the class where the inventory is in
There are 3 screenshots..
can you give me an example
huuh
Where i can Pput them, in witch room?
bathroom
he said a reference not a new instance
well if i would make a system like this i would have some class called Menu and whenever i want to open a menu for a player i would create an instance of that class and pass in the player through the open method. like so
// created the menu
QuotaMenu menu = new QuotaMenu();
//display to player
menu.displayTo(getPlayer());
//now i can do whatever i want with this Menu object which contains all the data relevant to the menu
ignore the name of the class this is just from some old plugin i opened
is it possible to set velocity with pitch and yaw?
i want velocity to work where player is looking
Can someone help?
should i touch velocity x and z or just y?
does hibernate works with spigot ?
getDirection() of teh player, normalize and apply as a velocity
No, never interupt the main thread
?scheduling
Ok, im leaving. Nobody can help so bye..
why do you ping me?
normalize vector or pitch and yaw?
You are in the wrong channel #help-server
vector
alr
setVelocity(player.getEyeLocation().getDirection().normalize())
alright
if its too fast or slow you can use .multiply on the normalized vector
@grim ice @tall dragon even more....
haha thats a good one
okay seems to work so far
how could i multiply it for example 10 times
after teh normalize().multiply(10)
ohhh i thought i can only multiply by another vector lol
okay now lets say i want to add 100 to Y of that vector
(the multiplied one)
what do you mean? You want to move it up 100 blocks or you want it to always have an arc?
hol up i think i found it
does anyone know why, when i kick a player it always sends this warn into console? [14:40:26 WARN]: handleDisconnection() called twice
What version are you on?
1.14
- Are you sure
- Why
it doesn't really mess anything up but i keep getting the warn for some reason
if i make a inventory in a class then make a getter for it will it still clone
It seems like its just a bug with your older version
no i should not
okay
alright well thats too bad then
if i make a variable timeleft with value System.currentTimeMillis()
and call that a few times, will its value changes to the current time?
?paste
why are the items in gui 2 duplicated so and so buggy
like theyre sometimes 3 or 4x and in random slots
No. the value of a variable will always be the same unless you re declare it.
ah so i have to call System.currentTimeMillis() every time
no
bump
@lost matrix do you have a clue?
you may have to actually debug something urself rather than ping people
How do I access the AI and pathfinding processes of an entity?
how do i remove a section from my custom .yml file?
set it to null
Set it to null
oh thanks
im s t r u g g l i n g
You need to dig into NMS for that. Its not part of the API
You only have one GUI. You are returnign the same UI every call
there are 2 pages
I would start at EntityInsentient
is this something?
public boolean checkCooldown(int secondsIfNotDefault) { // todo
long time = secondsIfNotDefault == -1 ? 5 : secondsIfNotDefault;
if (cooldowns.containsKey(p.getUniqueId())) {
if (cooldowns.get(p.getUniqueId()) > System.currentTimeMillis()) {
Utils.message(p, "§cPlease wait " + (cooldowns.get(p.getUniqueId()) - System.currentTimeMillis()) / 1000 + " more seconds!");
return true;
}
}
cooldowns.put(p.getUniqueId(), System.currentTimeMillis() / 1000 + time);
return false;
}
i++ inside your for loop means you are skipping entries
and you are only ever setting slot 53 (last slot)
if(i >= 55){
getGui2().addItem(item);
i++;
continue;
}
wdym
bruh?
im checking if the item being added is above the capacitity of the first gui so i can add it to the second
if (i == 54) {
i++;
continue;
}```Skips item 54
You should extract your side effects from that method.
A method should do only one thing. Get the cooldown left, add a cooldown or remove a cooldown.
You are adding a cooldown every time you check for the cooldown.
no, item 54 is your first item in yoru next page. 0-53
w h a t
54 items on teh first page = item 54 is item 1 on page 2
you are indexing from zero
so index 54 is item 55
Your code is a complete mess. Scrap the lot and start fresh
Well so far all I understand is you want two pages, for some reason
What is to be listed in these pages?
items that represent the names of the sections in config.yml
are they different per player?
no, they're locations
so same pages for all players?
https://paste.md-5.net/ohemebabut.java
thats without using second gui
uhuhrughrughrguhrguh
one sec
Hello.
I have a construction of 3x3 gold and above that a beacon. This gets built when you enter /guild create Test...
When you try to break a block, there is written, that you don't have the permission to do that. - Everything correct, till:
When you teleport far away; like to the spawn and then teleports back, you can destroy the spawn without any message and the menu, I created doesn't pop up when you interact with the beacon.
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.
Here is the code
What did I wrong?
Please ask, if you have questions.
@eternal oxide i feel like i can do it with inventory click event, or do u have another idea?
Untested but somethgin like this https://paste.md-5.net/umobukumag.cs
o
https://paste.md-5.net/uzokenoquf.java
How should I go about returning the player count in the method as an int?
You don;t there is a specific message to send to get a player count
You don;t respond to it yourself, Bungee handles that
I need to get the player count as an int tho
I'm aware
but I want to get what it returns as an int
that shows you how to get the player count as an int
ok
elgar, how do i get the starter page
pages.get(0)
o right
is it possible to remove the flight from the player in spectator?
yep, that would work
thank you so much, ill try it
I would use if (!pages.isEmpty()) player.openInventory(pages.get(0));
o
@eternal oxide
but the "next page" thingy in my click event
do i just check if the inventory clicked has a number in it
but how do i get the number
ahfauwghaugbauegbauabgereg
Theres many ways to do it
you could add meta to it when you get teh new page
so add meta to teh old next button when a new page is called for
or, don;t add the next until you are adding a new page
yeah i think i know it
wait
bruh lol
pages.IndexOf()
will work I think>
if(!e.getClickedInventory().getTitle.contains(ChatColor.GREEN) return;
int num = GuiMenu.pages.IndexOf(e.getClickedInventory);
player.openInventory(GuiMenu.pages.get(num + 1);
unless this throws a null or a index out of bounds or smth i should be fine
How do I get a nms PathEntity from a regular spigot entity?
look at that. It should give you an idea how
yes, set the size of pages on it as meta so you can read that off in yoru click event
Oh
doesnt that kill java principles or smth
like depending on strings or something idk
how can i reload an config on bungee?
public final ItemStack next(int number){
ItemStack next = new ItemStack(Material.ARROW);
ItemMeta nextMeta = next.getItemMeta();
nextMeta.setDisplayName(ChatColor.DARK_PURPLE + "Next Page (Page" + number + ")");
next.setItemMeta(nextMeta);
return next;
}
inven.setItem(53, next(Integer.parseInt("%d")));```
@eternal oxide
yeah using meta is almost impossible
cuz idk how to check in click event what inventory is it being clicked on
Using PDC
modify getNext to store it however you want
store a value and retrieve it in your click event
the parameter
if(event.getCurrentItem().isSimilar(GuiMenu.next(now what lol)))
i have to get the index of the inventory
the "next" item is in
why?
Are NMS names mojmap?
you get the value it points to
yes that's easy once i get the value it is in
You need to compile the moj mapped files yourself. On default they are obfuscated.
I am talking about the unmapped class names
the title has string as well
how do i filter
ints from strings
from a string containing both
The class names are not obfuscated. The exception are inner classes.
regex
Then you need to explain to me what you mean by "mojmapped"
"\\d+"
What are the unmapped classes named after
it is Mojang Map, MCP, Yarn or did someone just make them up
make an itembuilder class
There are no mappings applied. NMS literally contains the source content of the vanilla server jar.
\d is regex shorthand for [0-9], which means match anything between 0 and 9. The plus means "one or more", so numbers with string length 1 or more
ItemMeta meta = event.getCurrentItem().getItemMeta();
Pattern p = Pattern.compile("\d+");
Matcher m = p.matcher(ChatColor.stripColor(meta.getDisplayName()));
while(m.find()) {
int num = Integer.parseInt(m.group());
}
If this is your question, then your question is quite vague ^^ wdym by "NMS names"? If you mean class names then no, they are spigot/cb map
is that fine
how can i reload an config on bungee?
how to retrieve a float from a config file?
kinda, you only want one number so use if (m.find()) { int = m.group();
how can I create a 2D graph where it has two axes, x and y, where it will have a force that will make this point go up to a specific value and it will go down based on gravity equal to minecraft projectiles
private final float[]
velocity = new float[]{0, 0}, acceleration = new float[]{0, 0}, position = new float[]{0, 0};
public void applyForce(double[] force) {
if (force.length != 2) throw new IllegalArgumentException("Force must be a 2D double vector");
for (int i = 0; i < 2; i++) acceleration[i] += force[i];
}
public void tick() {
for (int i = 0; i < 2; i++) {
velocity[i] += acceleration[i];
acceleration[i] = 0;
position[i] += velocity[i];
}
}```
ItemMeta meta = event.getCurrentItem().getItemMeta();
Pattern p = Pattern.compile("\\d+");
Matcher m = p.matcher(ChatColor.stripColor(meta.getDisplayName()));
int num = 0;
if(m.find())
num = Integer.parseInt(m.group());
if(event.getCurrentItem().isSimilar(menu.next(num)))
player.openInventory(menu.pages.get(num));```
@eternal oxide i changed
is dat better
try it and see
get a double and cast it to float. I dont think floats are natively supported.
okay thanks!
and
private ItemStack next(int number){
ItemStack next = new ItemStack(Material.ARROW);
ItemMeta nextMeta = next.getItemMeta();
nextMeta.setDisplayName(ChatColor.DARK_PURPLE + "Next Page (Page" + number + ")");
next.setItemMeta(nextMeta);
return next;
}
any one can help me??
why not just get the page number from the inventory title in the click event?
what
if they clicked on next in inventory page 1, you get pages.get(1)
pages index on zero
so the number in teh title will be the index of the next page
pages.IndexOf
no
you need to know your current page
yes, regex the title
but it won't make a difference at this point
it would keep everything much simpler not messing with next
its just, if they click next ItemStack, regex the title and pages.get(regex result)
Matcher m = p.matcher(ChatColor.stripColor(event.getClickedInventory().getTitle()));
yes
also why is this weird website using one letter variables
because its old
i would like to know how to add the glow effect to items
without addind an enchantment and using the hide flag
in 1.8 i can add the empty nbt tag "ench" among with any random tag
but in 1.16 it is not possible (the item dont glow)
I think in 1.16 you have to do something along the lines of adding an enchantment(say, luck) and then hiding the tag
🤔
I don't think it's that big a deal since luck doesn't do anything anyway
#help-development message can someone help me with it
Caused by: java.lang.NumberFormatException: For input string: "%d"
why have you got a %d in your title? That was replaced with String.format
Inventory inven = Bukkit.createInventory(null, 54, ChatColor.GREEN + String.format("Warps: (Page %d)", pages.size() + 1));
private Inventory newPage() {
Inventory inven = Bukkit.createInventory(null, 54, ChatColor.GREEN + String.format("Warps: (Page %d)", pages.size() + 1));
Pattern p = Pattern.compile("\\d+");
Matcher m = p.matcher(ChatColor.stripColor(inven.getTitle()));
int num = 0;
if(m.find())
num = Integer.parseInt(m.group());
inven.setItem(53, next(num));
pages.add(inven);
return pages.get(pages.size() - 1);
}```
^ this is what i mean
now it should not error
why do u have %d in the format tho @eternal oxide
if so how does it know the number u want
I have a BukkitRunnable which is on runTaskTimer - is there a way to delay the next iterations of the loops?
on sec
next(num)
i got the title of the inventory
and new page
That's the parameter of the Item
theres no need for any of that
one sec
in here nextMeta.setDisplayName(ChatColor.DARK_PURPLE + "Next Page (Page" + number + ")");
i dont see what i sent is horrible
Are you kidding me
So I am trying to use Minecraft's internal debug plugin message channels
But spigot does not let me send the data unless I register it
But when I try to register it, it throws because it's a reserved channel
Despite the spec clearly saying they do not need to be registered
wtaf
?paste
which spec?
Register as a listener https://paste.md-5.net/asocafumux.cs
Since 1.3, Minecraft itself uses several plugin channels to implement new features. These internal channels use the minecraft namespace. They are not formally registered using the register channel. The vanilla Minecraft server will send these packets regardless, and the vanilla client will accept them.
Spigot's spec can differ from minecraft's soec
Spigot literally wraps around the vanilla server
It modifies it quite intensively
u removed inven.setItem(53, next(num));
in newPage()
So then why are they marked as reserved
yes, not needed
If spigot does not respect them
oo ok
you only need the basic next ItemStack
you may need to ask that to the person that changed this (probably dinnerbone)
He most likely implemented the interface
API = Application Programming Interface, I would consider plugin channels APIs
woah calm down vatuu
plus, bukkit has some more abstraction
Gotta love when someone here doesn’t know what the fuck they’re talking about
yeah chill fam
everyone learns
not like you know everything
The thing is that I am pretty sure that this behaviour has been like that for years, perhaps even for a decade now
Which is why I said that it is most likely (but not 100%) that this behaviour originated from dinnerbone, who maintained bukkit at that time
A: Minecraft does not have a API spigot utilizes, it's built on top of a patched vanilla server
B: Plugin channels have a register system which spigot enforces, but the debug channels do not require it.
C: Spigot recognizes these debug channels and prohibits registration of those because they do not need to be registered
D: And yet spigot still demands that sending data on those channels has to have it registered first
So just drop it and let someone who knows more see if they can provide the information he’s requesting
It's an flaw with the implementation of the API, I am simply saying that this flaw likely has been there for years
This just sounds like shoddy api design on spigot's side
I would say bukkit is at fault
?paste
hey i use this method in loop https://paste.md-5.net/ecibacaqej.cs and it works right times but summons only one armor stand pls help fix
Mojmap is the recommended way to go actually
@eternal oxide it it supposed to not set the "next" item if the inventory is not full yet
if the inventory is not full you will have no next
alr alr
you my have to change if (i == 53) { to 54
It won;t break anything but it may leave one slot empty
test it and find out
i have this working for the first gui
the second gui, it doesnt work
why
they both have the title Warps
Can I modify a block's drops in a BlockBreakEvent?
yea
make it air then get players location then do a natral drop
natural drop
yeah I'm doing that right now but if another plugin cancels it or does something else that leads to duping
thought there might be a better way, integrated into the API
hm
What makes you think its failing on title?
will just check if its already cancelled or sth, idk
idk just a guess
and theyre the legit same
except the title
so what could it be
some1 is gonna tell me to use debugs lol
please help i really need fast help with this https://paste.md-5.net/ecibacaqej.cs i call this method 3 times but armor stand spawns only once and first PLS HELPPPPPPPPPPPPPPPPPPPPPPPPpp
Yep, debug and find what test is failing
Ok so im my plugin i use an array list that gets online players gets there heads then fills the inv, How can i make like a "page-2 / unlimited "
So people with more then 45 players online can use my plugin ?
well there would be an arrow on slot 44 that would then take them to page 2 Exetra
look thru the convo between me and elgar
i asked him a similar question
also why 45
use 54
its 9 slots more
good point
did u get an answer?
public static void openBanMenu(Player p) {
ArrayList<Player> list = new ArrayList<>(p.getServer().getOnlinePlayers());
Inventory bangui = Bukkit.createInventory(p, 54, ChatColor.WHITE + "[" + ChatColor.RED + "Player List" + ChatColor.WHITE + "]");
for (Player player : list) {
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
SkullMeta sm = (SkullMeta) playerHead.getItemMeta();
sm.setOwningPlayer(player);
ItemMeta player_meta = playerHead.getItemMeta();
playerHead.setItemMeta(sm);
ItemMeta meta = playerHead.getItemMeta();
meta.setDisplayName(ChatColor.WHITE + player.getDisplayName());
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GOLD + "Player Health: " + ChatColor.RED + player.getHealth());
meta.setLore(lore);
playerHead.setItemMeta(meta);
bangui.addItem(playerHead);
{
p.openInventory(bangui);
}
}
}```
oh noice