#help-development
1 messages Ā· Page 1778 of 1
no clue, look in its config
meh not worth the work lmao I was just testing on priv server anyways
real server wont have ess
IDK if you're being serious or not lol
WHY DO YOU HAVE 3 NESTED RUNNABLES!
because they need to be run one after the other
Also...
Should be using long instead of Long
Ping isn't imported (or doesn't exist)
The IDE is telling you that you can use a lambda, and you don't 
well yes
but they aren't really in a logical fasion
it goes 10->5->1->announcment
Jesus fucking christ
And?
i suppose you could do if(10)->5
You can schedule them all at once you know
And write a helper method
That is horrible
Or you can run it once per minute
This is actually good, no clue what the others are on about.
It's very clean.
And then check how many minutes are left and do the appropriate action
Maybe they've haven't actually coded before?
š¤
It's true, I've been faking it this whole time
Obvious troll is obvious
Yeah but honestly, it's messy but it should work?
I can drive a screw in with a hammer and it will work, but its not the best thing to use.
but here it's redundant get players
And you have redundant runnables
One runnable that counts down an int each minute
When int == 10 do one thing, when int == 5 do another, etc
ah aight thx
wtf is that
Art
i'm trying to find a way to modify the item tooltip players see without actually modifying the item's nbt data server side. is this even possible, and if so, could someone point me in the right direction? googling yielded little.
Packets
Specifically PacketType.Play.Server.WINDOW_ITEMS and PacketType.Play.Server.SET_SLOT
awesome, thanks!
hey so i have an issue with formatting on some Component stuff
essentially, the formatting from the component mute transfers throughout everything else
how should i fix that?
isn't there a reset function
well of course it does, since you did staffFormat = mute lol
consider using ComponentBuilder, it is much clearer than making components directly
A story in 3 parts
yeah
let me try smt first
also
how hsould i .getPlainText() of a BaseComponent[]
i'll brb, if you do have a response pls ping me
its just an empty white space, that has all formatting removed
thats what im thinking
It should be .append(mute).append(" ").append(formatRevised)
does that actually matter
Uhh
isnt that the same thing
idk i thought it'dh elp im removing it lmfao
Not necessarily
ah
The builder might clone on each step rather than mutating the internal state
ah
so this is better?
(i like spacing things like that, its easier for me to read)
how would I make something run when day turns to night
you'd probably have to make a runnable check the time every now and then
compare it to if is no longer day
other than that
Thatās basically the only option
well you could have a command block run a command constantly and check the time when that command is run
or listen to entity move event and check the time whenever an entity moves
or player move event
there's a entity move event?
Yes
bruh
actually i cant really say "bruh" but still
oh wait there isn't
i forgot
you got me there
check player move event then
or just use a runnable
That is likely slower than just using the runnable
it 100% is slower
so a runnable is the best solution?
im having more issues now, with the BaseComponent[] thingy dealio
now formatting just copies over to each and every text component
how do i reset formatting per text component
especially where there shouldnt be formatting, i.e; hover events, etc.
Does anyone have any advice to how I could stop the effects of an enchantment? I want players to be able to have quick charge on their bows, but I don't want that effect to do anything (unless players have unlocked something) [not a paywall or anything]. Currently, we are completely removing the enchantment from crossbows entirely and I want to stop doing that.
Fairly sure that's handled clientside so I'm not sure there's anything you can do about it other than removing the enchantment
You could always fake the enchantment, so it looks like it's there but it's really not
Yeah unfortunately, it's not functionally feasible to do that.
You could maybe remove the enchantment in the outgoing packet
I'm not familiar with how that works. Do you mind elaborating a little bit?
Use protocollib to intercept outgoing packets and remove the enchantment
Specifically these two
hello??
.reset?
can someone help me with my plugin?
I am getting this error: at me.deadshot.vault.Main.lambda$RestoreInvs$0(Main.java:49) ~[?:?]
at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
at me.deadshot.vault.Main.RestoreInvs(Main.java:47) ~[?:?]
at me.deadshot.vault.Main.onDisable(Main.java:34) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:266) ~[spigot-1.17.1.jar:3276-Spigot-3892929-b58f429]
please ping me if you have an answer
line 49 is probably a collection.forEach
based on the fact that error relates to a lambda and the top stacktrace element is Iterable.forEach
soooo
probably a NPE tbh
but yes please include the actual fucking exception
how the fuck are we supposed to decode whatever is going on from this
Guys tone down the language please
It is when I declared a method to restore an inventory after the server has been reset, I am trying to save hashmaps to a file.
Ok
public void RestoreInvs() {
// the code that restores the inventory from the config.yml
this.getConfig().getConfigurationSection("data").getKeys(false).forEach(key ->{
@SuppressWarnings("unchecked")
ItemStack[] content = ((List<ItemStack>) this.getConfig().get("data." + key)).toArray(new ItemStack[0]);
menus.put(key, content);
});
}
And which is line 49
is it not a class cast exception?
Thereās a toArray
I think the problem is that you can't cast that data to a list of itemstacks
Line 45 is public void restoreInvs
ye then it's probably a ClassCastException
Unlikely
so this makes sense to you? (List<ItemStack>) this.getConfig().get("data." + key)
what is the fuckin' error lmao
Theres a toArrayā¦
md_5 you don't understand
I'm highlighting the spot where List is actually casted
the toArray doesn't fuckin' matter bc I already verified it makes sense
the part that is strange is trying to cast the return value of get to List<ItemStack>
Should the config.yml file be in src or project folder?
Should use getList but same thing really
jesus christ people we need errors
code is good but errors tell us the actual problem
that is a stacktrace
what is the error type
getCommand or getItemMeta is probably returning null.
the former meaning you don't have the command configured in your plugin.yml
I don't know which contexts getItemMeta returns null tho, not like Bukkit's docs say anything
btw if you're working in newer versions, the NPE will show exactly what caused the exception to be raised
src/main/resources if you're using Gradle/Maven, or your source folder if you aren't
Yeah I did that⦠still the code is not working
then its probably not the fault of config.yml
The rest of the plugin is working, it is having a problem in taking the info from the config.yml
That deels like codedred
Seems
Stupid autocorrection
EnumSet
Create an enum set
Add all materials from configs to it
And then check if set contains your block material
I am trying to implement per-player damage multipliers (eg. some may take 2x damage and others may only take 0.5x)
On plugin startup I'm loading all the settings from my config file, but how should I go about caching it?
Create a HashMap contatining player UUID and the float multiplier or is there a better / more efficient way?
a hashmap would be good i think
quite efficient
its O(1) time complexity so it should be fast no matter how many players you have
Can anyone help with bungee supervanish?
Could anyone help me with hooking into MVdWPlaceholderAPI? I have copied the repository and dependency from the SpigotMC page, and it doesn't seem to work...
Alright, thank you orby š
Hi, is there by any way that an event can't be fired (even if it's register) ?
you could also use the methods in https://hub.spigotmc.org/javadocs/spigot/org/bukkit/metadata/Metadatable.html
which Player inherits from, but then all players would have to be online so i still recommend a HashMap
declaration: package: org.bukkit.metadata, interface: Metadatable
@EventHandler(priority = EventPriority.HIGHEST)
public void onProjectileLaunch(ProjectileLaunchEvent e) {
System.out.println("trigger");
if (HGuard.getByLocation(e.getLocation()) == null) {
return;
}
HGuard hguard = HGuard.getByLocation(e.getLocation());
if (!hguard.isPvp())
e.setCancelled(true);
}```
Some times (when i'm in a area protected of my plugin) the message trigger is not fire. How an event can't be fired everytime ?
Can an other event can block the fire of an another event ?
do you have any other plugins installed?
nop any
no clue
To what evetns are you listening
maybe println is broken itself or some projectiles dont trigger the event
i use a bow for my test, outside my area the event is trigger as usual but when i enter in my area the event is not trigger
somethjing outside the event is blocking it
what is "your area"
ah didnt saw
and i don't understand what could block the fire of this event
HGuard is an object containing coordinate to pretect area with a lot of parameter
are you listening to/cancelling any other events?
A lot but i have any problem with them, only ProjectLaunchEvent
exactly
why not just using worldguard, or doesnt it support certain features you need?
The only thing that i can conclud, there is something blocking the event to fire but what ? i d'ont even know if we can cancel with en event all other event or something like this
maybe replace
System.out.println("triggered");
``` with
```java
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "triggered");
i'm not controlling all, and i just want to code it by my self
might be more reliable or something because i have no idea why it wouldnt work
plugin.gerLogger() š
Probably a dumb question but did you register your listener
they said it fires sometimes
so im assuming it is registered
Look HGuard object and Hguard Listener
of course
on what version you are
change nothing the version i'm on
i change the print and i tell you, but even if i print you the fire the event is canceled
The message trigger is not print, the event is btw canceled, and the area hasPVP TRUE
so any sense
any
any error
no idea what that means
also i have no clue what could be happening
maybe md_5 could help idk
The only thing, that append is an other event intervening that cancel the event in the area
no errors?
but it's the only moment i called the event PlayerShoot
Can anyone help with bungee supervanish?
whats wrong with that?
mine aint workin
public void onBlockEat(EntityChangeBlockEvent e) {
``` why is it called `onBlockEat` lmao
link to wither block eat
yummy
@EventHandler
public void onCustomItemThrow(ProjectileLaunchEvent e) {
if (e.getEntity().getShooter() instanceof Player) {
Player shooter = (Player) e.getEntity().getShooter();
if (CustomItemStack.hasTag(shooter.getInventory().getItemInOffHand())) {
CustomItemLaunchEvent customItemLaunchEvent = new CustomItemLaunchEvent(shooter, CustomItemStack.getCustomMaterial(shooter.getInventory().getItemInOffHand()), shooter.getInventory().getItemInOffHand(), e);
Bukkit.getPluginManager().callEvent(customItemLaunchEvent);
return;
} else if (CustomItemStack.hasTag(shooter.getInventory().getItemInMainHand())) {
CustomItemLaunchEvent customItemLaunchEvent = new CustomItemLaunchEvent(shooter, CustomItemStack.getCustomMaterial(shooter.getInventory().getItemInMainHand()), shooter.getInventory().getItemInMainHand(), e);
Bukkit.getPluginManager().callEvent(customItemLaunchEvent);
return;
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onProjectileLaunch(ProjectileLaunchEvent e) {
System.out.println("trigger");
if (HGuard.getByLocation(e.getLocation()) == null) {
return;
}
HGuard hguard = HGuard.getByLocation(e.getLocation());
if (!hguard.isPvp())
e.setCancelled(true);
}
```the only two ProjectileLaunchEvent of my plugin
yep
can you listen to the same event twice?
i do it a lot of time in my plugins and yes
you just need to handle correctly the priority
oh ok
so the
@EventHandler(priority = EventPriority.HIGHEST)
public void onProjectileLaunch(ProjectileLaunchEvent e) {
``` is supposed to be run first?
because the priority is highest
nop latest, hi will have the last world of cancel event or not
HIGHEST priority makes it run first i think
declaration: package: org.bukkit.event, enum: EventPriority
can i get a cookie now?
no
oh no
its a weird problem
i have absolutely no idea whats happening
maybe ask on https://www.spigotmc.org forums
anyways do you need to close a PreparedStatement?
?
yes, always close after using it
thats sql
oh yeah
oki
Use try-with-resources
Yes lol
Why not hikari?
ItemMeta#setLore(List<String>); is deprecated
does anybody have any idea which is the new method?
can I somehow prevent the Particle.SPELL from moving automatically? I mean this weird kind of fading out thing they do when you spawn them at a specific location.
it is?
ye
doesnāt say it is on the jd
ItemMeta#setDisplayName(String)
deprecated aswell
ye
there you go
ItemMeta::lore
it probably wants components
and ItemMeta::displayName
go to paper if you are using paper api
ok
idk i'm using mysql or sqlite
Hikari is a connection pool
?
probably handled client side
and what are the advantages of it?
so I cant change it?
doubt it
that would be really expensive on the server to manage
so if i was mojang that would be client side
is there any other particle that doesnt move like that
they all tend to have animations really
the server only tells the client when/where to spawn them
I did it with DustOptions
why
Meh the naming
Can anyone help me hook into MVdWPlaceholderAPI?
I copied that repository and dependency, it didn't work..
Btw, how can I make, that snowgolem will target fire? I quite undersand custom entities, but I don't know any good way find the block with fire.
what about this doesn't work?
guys is it okay to extend JavaPlugin without adding onEnable() and onDisable() ?
add <scope>provided</scope> to the papi as well
yeah, but nothing will get run lol
oh okay then
you cant register any events or commands
yeah they have to go in the onEnable block otherwise none of your other code will be run
imma fix it
so basically you need an onEnable
It keeps saying "Cannot resolve be.maximvdw:MVdWPlaceholderAPI:3.1.1"
onDisable often isnt needed
one sec ill try
kk
but he can register chunk generator for example
i thought that needed an onEnable, hmm probably not then ig
it seems like the repository isnt working
you register it as this (there is a function that should return the generator)
@Nullable
@Override
public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, @Nullable String id) {
return new Generator();
}
Like the jar file?
How do that?
do you use intellij?
Yes
so download it from the spigot page
Done
File -> Project Structure -> Modules -> Dependencies -> + -> Jars or directories -> select jar -> Change scope on the right to Provided
Alr
- Clone sources from github
- Build and install mvdw to your local repo
- Use
just dont do this unless you Have to
guys if i put a recipe in a public void recipe() and just put that recipe in will it still work?
because i used to just let my recipe out in the open at the main class but now when i put it at separate classes i do not know if it will work or not
hello how to modify the nbttagcompound of an armorstand in 1.12.2 nms ?
there is no method for it
Why
cause there is no pdc api in 1.12.2
then maybe you cant?
you can
idk i never used 1.12 before
?pdc
1.12.2
i did not answered to you
"1.14 pdc api"
1.12.2
i know
the pdc is in 1.14
and i want to use NBTTagCompounds
what?
to make it in 1.12.2
Probably need to use nms or the obsolete tag container api thingy
i want to use nms
^
?
They shoot projectiles
Look at the cat AI, specifically how they target chests
oh, thanks, I didn't know, that cats target chests xd
but maybe it's possible because chests re tile entities, but I;ll look at it
I believe I might be working with some UNSPECIFIED_META and for some reason I cannot pick out the getLore() component. (Keeps giving me NullPointerExpection or something of the sort).
How do i know if the "weapon" in this case has no lore attached?
public class EnchantRename implements Listener {
// An array of items that are prohibited to the rename event.
Material[] weapon = {Material.DIAMOND_SWORD, Material.DIAMOND_AXE, Material.BOW, Material.IRON_AXE, Material.IRON_SWORD, Material.STONE_AXE
, Material.STONE_SWORD, Material.WOODEN_AXE, Material.WOODEN_SWORD, Material.GOLDEN_SWORD, Material.GOLDEN_AXE, Material.NETHERITE_AXE, Material.NETHERITE_SWORD};
Plugin plugin;
public EnchantRename(Plugin plugin) {
// Bukkit.getLogger().warning("I got called.");
this.plugin = plugin;
};
@EventHandler
public void onEnchant(PlayerItemHeldEvent e) {
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
for (Material m : weapon) {
if (m == item.getType()) {
String oldname = Objects.requireNonNull(item.getItemMeta()).getDisplayName();
// This check is if the item has been updated or not.
// Bukkit.getLogger().info(String.valueOf(oldname.toCharArray()[oldname.length() - 1]));
int count = 0;
Bukkit.getLogger().severe(String.valueOf(item.getItemMeta().toString()));
if (!Objects.requireNonNull(item.getItemMeta().getLore()).isEmpty()) count = item.getItemMeta().getLore().size();
... // Code here that utilises the count var.
Errors initially looked like this with the .getLore() function
[23:01:02 ERROR]: Could not pass event PlayerItemHeldEvent to Dropbox v1.0.0
java.lang.NullPointerException: null
at java.util.Objects.requireNonNull(Objects.java:208) ~[?:?]
at xyz.nekonii.hexcraft.dropbox.listeners.EnchantRename.onEnchant(EnchantRename.java:42) ~[Dropbox-1.0.0.jar:?]
and just printing the .getItemMeta()
[23:02:50 ERROR]: UNSPECIFIC_META:{meta-type=UNSPECIFIC, enchants={PROTECTION_ENVIRONMENTAL=12, DURABILITY=12}}
[23:02:50 ERROR]: Could not pass event PlayerItemHeldEvent to Dropbox v1.0.0
java.lang.NullPointerException: null
Check it lore is null
Would a ... == null suffice or is there a built-in feature for checking nulls?
But there's..?
Is there? Then use that
hi
Though == null makes idea shut up
why does this command not work for me ?
sender.sendMessage(utils.chat(Plugin.getConfig().getString("credit")));
idk
it shows error on .getConfig
Because itās not a static method
use your main class' instance
get an understanding what class is and whats the difference between static and non static context
okay
will the config file be directly placed in to a folder with this ?
or i need something else to be added ?
the cat ai seems to just loop the blocks, but this can work only in smaller ranges, so it's not usable for the snowman
declaration: package: org.bukkit.plugin, interface: Plugin
So I tried building it, but it says that "package be.maximvdw.placeholderapi does not exist"
add the repo
Forgot to mention that you cant mix this with maven
How do I add the repo?
you will have to install it to maven local
How do I do that?
see this
Alr
I'm kind of confused....
I don't understand how u do it.....
Can anyone show me how to do it
this one
you need to give the arguments correctly
let me try and make the cmd
mvn install:install-file -Dfile=<path-to-file> -DgroupId=de.maximdw -DartifactId=MVdWPlaceholderAPI -Dversion=2.1.1-SNAPSHOT -Dpackaging=jar -DgeneratePom=true
you just need to add the path to the file
Where do I enter the command?
cmd prompt
?paste
https://paste.md-5.net/iluwuzebox.cs
Hey guys. I have a problem where the code Ive written makes the projectiles from the blaze into different projectiles. somehow the vectors I set make the new projectiles fly towards the targeted player (which is what I want) but then they turn around when theyre at the players position. any ideas?
The bossBlazeTargetMap saves the blazes Entity ID as a key and their targetted Entites UUID as a value.
Please disregard the weird chances setup, havent gotten around to changing it.
Just setting it to the original fireball vector does not work. they always fly in the same direction, no matter where the player is.
Probly the world?
?
cant i just execute a sql Statement?
do i really need a PreparedStatement
i'm trying to create a table
How do I subtract 1 from the amount of item that a player has
p.getInventory().getItemInMainHand().getAmount();
i know this one, hold on
setAmount(getAmount()-1)
š³
sheeesh
ill see if it works
also i am dumb why didnt i think of that
yes it work thx
for now ive fixed it by applying the same vector a couple times over 5 seconds or so, not a perfect fix but it works.
Anyone know some sort of custom crafting gui api that i can use? Similar to hypixel skyblock's crafting
Hello, i'm looking to fill an empty cauldron with lava on it, someone know how to ?
I have find Levelled class but it's seems to be only for the amount of fluid not for fluid type
Yes you can
Thats what Regular statements dor
I've got an exception: java.lang.NullPointerException: Cannot invoke "String.toUpperCase()" because the return value of "org.bukkit.configuration.file.FileConfiguration.getString(String)" is null at md.mirrerror.thewalkingdead.utils.ItemUtils.getCustomItemFromConfig(ItemUtils.java:60) ~[?:?]
Line with the exception: Material material = Material.valueOf(fileConfiguration.getString("CustomItems." + name + ".Material").toUpperCase());
But System.out.println(fileConfiguration.getString("CustomItems." + name + ".Material") == null); prints [17:38:20] [Server thread/INFO]: false
yeah
Material is null?
And this System.out.println(material); prints [17:38:20] [Server thread/INFO]: DIAMOND
use match not valueof
Can you update a server-texturepack mid-game?
without people having to redownload it
like just change a specific texture
no
anyone?
nothing changed
is this a good way to save data periodically starting a second after oneEnable?
ok show your yaml
Custom Crafting GUI Api
hey so uh... my config generates empty?
but I can still access the data from the code
<the default config>
in onEnable saveDefultConfig()
I did
then it won;t be empty, unless the config.yml in yoru jar is also
Why doesn't it work?
@EventHandler
public void onCraftItem(CraftItemEvent event) {
if(!(event.getRecipe() instanceof ShapedRecipe)) return;
if(!RecipesManager.getShapedRecipes().contains((ShapedRecipe) event.getRecipe())) {
event.setCancelled(true);
}
}
I want to block all the recipes except my recipes, but it blocks all the recipes (default and my recipes)
is there a shorter way for !(bool) && !(bool)?
Explain more
Like what are you trying to do?
aha
how can I check if a number is a multiple of another number
number % other == 0
if (number % otherNumber == 0) {}```
number % otherNumber == 0
š³
@tardy delta Yup, DeMorgan's Law
is this one even right?
yes
ugh
shh not again
ugh
Is there a way for throwing exceptions using the run() method?
false, false -> true right?
true, true -> true
false, false -> true
Wym
You can sneaky throw runtime exceptions
But that need a try catch
public class Run implements Runnable {
protected <E extends RuntimeException> void exception(Throwable throwable) { throw (E) throwable; }
@Override
public void run() {
try {
execute();
} catch (Throwable throwable){
exception(throwable);
}
}
public void execute() throws Throwable { }
}
I find that on google. What do you think?
runtime exceptions
Well, not sure if that would work on non runtime exceptions š you are doing a cast
Use it
Ah wait
use a method of it
woah i use 5 times JavaPlugin#getPlugin(MainClass.class)
You generally want to avoid naming it Main
?main
ez guess
I use this:
private static MainClass instance;
public void onEnable() {
instance = this;
}
public static MainClass getInstance() {
return instance;
}
Then you can simply do MainClass#getInstance()
i dont use that
i couldnt find that coma
Itās next to 1 on American keyboards
š³
I use Uruguayan keyboard btw
)
Maybe you could exclude classes that extends JavaPlugin from intellij inspections?
I think im the only one here from uruguay.
Who you are talking to? and explain context
anyways can i assume that if you're using something as that, the instance is the same one as the plugin manager and stuff is using?
To kragleh
Just ignore it though, thats not really a problem that you should care about
question should I make every event in 1 class or separate every event's class
if you'd use your plugin instance in other classes the warning will disappear
wdym? Event listeners?
I have a dought from java pure. Its there a way of getting class instance like: getClassName()#getMethod()?
yh
.newInstance()
What a bullshit
but that creates a new one
Because with javaplugin I set the instance = this; but with pure java that its not possible
heh?
Just dont use singletones
you would use a singleton pattern
Pass your objects in constructors as any other depenency
You shouldnt use plugin in enums and utility classes
so which one?
I use JavaPlugin.getPlugin in enums
separate or all in one
If you use plugin in enums you are doing something wrong
me too 
enums are static, plugin is not by its natutre
Namespaced keys
Although you donāt need a plugin instance for those anymore so I could remove it
Enums are being initialized on class loading, before plugins
you need. Constructor without plugin is for internal usage and its deprecated
Why doesn't it work?
@EventHandler
public void onCraftItem(CraftItemEvent event) {
if(!(event.getRecipe() instanceof ShapedRecipe)) return;
if(!RecipesManager.getShapedRecipes().contains((ShapedRecipe) event.getRecipe())) {
event.setCancelled(true);
}
}
I want to block all the recipes except my recipes, but it blocks all the recipes (default and my recipes)
Try using recipe Keys instead of actual recipes
ok, sorry
ty, I'll try it now
Which was it?
it's fine if it's not used
What do you want to do?
White. Thats logger
NamespacedKey.fromString
thats unecessary parsing
Null Pointer Exception, or in other words your program was trying to use something that was null
nullpointer, calling null.someMethod()
it works, tysm
the itemmeta can be null, the lore
i never understood the difference between null and new ItemStack(Material.AIR)
you can call methods on air itemstack
Air can't have meta
But you can call other methods on it
you still can getType and getAmount
Like isAir
2 air š¤
Btw is there any "R" alternatives in hextalk?
i know this is a weird question but what do i do when i created a soup instead of lines of code :(
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.meta.ItemMeta.getLore()" because the return value of "org.bukkit.inventory.ItemStack.getItemMeta()" is null
if(player.getInventory().getItemInMainHand().getItemMeta().getLore().equals("[§2Reusable Mob Changer]")){
player.sendMessage("Clicked on spawner correctly");
```
I get these error message but when i run this it works and returns [§2Reusable Mob Changer] could some one help pls?
```java
if(action.equals(Action.RIGHT_CLICK_AIR)){
String str = player.getInventory().getItemInMainHand().getItemMeta().getLore().toString();
Toolkit toolkit = Toolkit.getDefaultToolkit();
Clipboard clipboard = toolkit.getSystemClipboard();
StringSelection strSel = new StringSelection(str);
clipboard.setContents(strSel, null);
}```
getItemMeta only returns null on air
wtf are you doing with system clipboard
getting item meta
yes check first whether the the item has meta
From system clipboard????
it only has lore
Lore means it has meta
how else do u suggest i copy the item meta?
well then yes i do have meta
But the item you are holding may not always be that item
If you are holding nothing, then it wonāt have meta
what are you trying to do, lmao? ItemMeta.clone?
i always first if all this only then i ask for the lore
(local variables exist)
You really could use a variable there
no
But yes that is correct
Wdym by copying ItemMeta?
^
hmm?
ah it works now ty
and I am idiot
player.getInventory().getItemInMainHand().getItemMeta().getLore().toString().equals()
not player.getInventory().getItemInMainHand().getItemMeta().getLore().equals()
Ehhh....
getlore returns list <String>
ToString is worse
have you ever heard of else if statements
ok but i need people to help me know bc i have also barely any knowledge with yml, so is this all within boundaries of good syntax?
whats that
Thatās very hard to read
But how does that code have anything to do with yml?
config file
Yuh but itās not yaml specific based on that code you sent
its not configuration tho i just save it there for now
Alright
i meant the Main.instance.getConfig()set thingies
i mean whether it works
Papple try and see
:panik:
not like i have 5 others errors in my script but yeah you have a point
If itās a java class then it is not a script
But yes show those 5 errors then maybe?
js :kekw:
Why did i got pinged
the panik
about using the system clipboard
dont use event.setCancelled(false)
thats defaulted
line 49, nullpointerexcpetion Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
this line? timesHitList.set(playerList.indexOf(p.getUniqueId()), System.currentTimeMillis() - 5000);
is timesHitList a map?
it says the size is 0 and you're trying to get index 0 (the first element)
yes
How can I get remaining time from a LocalDateTime? I want to compare it with 24 hours for example. So get remaining time from 24 hours and the LocalDateTime, idk If I explain it clearly.
Maybe you need Duration and not LocalDateTime?
what are you trying to do?
Getting remaining time
countdown you mean?
Something like that, yeah.
Hmm? Maybe Duration.between(date, date.minusDays(1))
I want to get a nice format too, like 2h 25m for example.
Basically I have a reputation system, and you can only give 3 reputation, and after that it will start countdown 24 hours till get your reputation usage reset.
wait so you mean i cannot use list.set if the list is empty and instead should use .add
social credit
i dunno
hmm
why not just adding?
bc they have to be in an order since i use multiple lists as maps basically
basically if the first list contains values they will be associated with the values in the other list at the same index
okay at least ik what the problem
if you use a set i guess the values will be overwritten if they are already in the set
Hey people is there way of adding a fake player to spigot server. So we can use the spigot messaging channel without online players?
add npcs?
No no fake players.
npcs are in theory fake players
you could also just jump to an alternative
with a gameprofile
I want to do this, connect fake players to proxy, so the spigot server has recipients for the plugin messaging channel
just use redis
I use shared hosting
NamespacedKey key = new NamespacedKey(new StoneMind(), "calcite");
Im trying to reference my main plugin class (StoneMind) in a NamespacedKey, is it correct?
I cannot host redis
dont create new instances
btw what is redis?
do you know how to create an entityplayer that affects the Bukkit#getOnlinePlayers() Collection?
im trying to make a custom recipe
edit: being stupid
He?
Explain
With redis I need a hosting bruh
I use a shared hosting and i dont have money to buy a redis hosting service
Thats what i refer to
anyway how would I reference my main class then?
search up redis pub/sub
are you using a instance = this or something related in your main class?
You need to install redis somewhere
Omg
You cant use redis if you dont have installed it
the NamespacedKey is in another class, so i cant use this
i know
And i dont use a vps where i can install redis. I use a hosting
public class MainClass {
private static MainClass instance;
public void onEnable() {
instance = this;
}
public static MainCLass getInstance() {
return instance;
}
}
in your other class
new NameSpacedKey(MainClass.getInstance(), " ");```
oh ok
it still doesnt seem to work
what doesnt work?
i tried your method and tried registering a custom recipe
wait holduip
ok nvm it worked
how can I get a value from a string like "Damage: +%float%"
if its Damage: 1234567890 then use
Long.parseLong(lore.get(line).substring(8));```
hmm
maybe i can combine that with starts with
but like what can I do about the colour codes?
ChatColor.stripColor(String) is something u guess
Use pdc for the love of god
lore is not for data storage
he says it is from lore
smh disabling tabcomplete for console
i'm trying to execute a method every time a overridden method is called without putting it in every overridden method
guys
i'm calling spigot().respawn(); on a player on PlayerDeath event, but the dead player picks up the items dropped in the location they died, resulting in a keep-inventory like behaviur
anyone have issues with unresolved references when trying to compile a module in intellij that depends on another module in the same project?
I've run maven install on the project i need as a dependency and I see it in my .m2 folder, however when compiling the second project it gives me unresolved reference errors and fails to compile
public class npc {
private static List<EntityPlayer> NPC = new ArrayList<EntityPlayer>();
private static DataWatcher watcher;
public static void creatNPC(Player p, String skin)
{
MinecraftServer s = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer w = ((CraftWorld) Bukkit.getWorld(p.getWorld().getName())).getHandle();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(),skin);
EntityPlayer npc = new EntityPlayer(s,w,gameProfile,new PlayerInteractManager(w));
npc.setLocation(p.getLocation().getX(),p.getLocation().getY(),p.getLocation().getZ(),p.getLocation().getYaw(),p.getLocation().getPitch());
watcher = npc.getDataWatcher();
watcher.set(new DataWatcherObject<Byte>(16, DataWatcherRegistry.a), new Byte((byte) 127));
npc.setHealth(100);
String[] name = getSkin(p,skin);
gameProfile.getProperties().put("textures" , new Property("textures",name[0], name[1]));
addNPCPacket(npc);
NPC.add(npc);
}
public static String[] getSkin(Player p, String name)
{
try{
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
InputStreamReader reader = new InputStreamReader(url.openStream());
String uuid = new JsonParser().parse(reader).getAsJsonObject().get("id").getAsString();
URL url2 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false");
InputStreamReader reader2 = new InputStreamReader(url2.openStream());
JsonObject property = new JsonParser().parse(reader2).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
String texture = property.get("value").getAsString();
String signature = property.get("signature").getAsString();
return new String[] {texture, signature};
}
catch (Exception e)
{
EntityPlayer player = ((CraftPlayer) p).getHandle();
GameProfile profile = player.getProfile();
Property property = profile.getProperties().get("textures").iterator().next();
String texture = property.getValue();
String signature = property.getSignature();
return new String[] {texture , signature};
}
}
public static void addNPCPacket(EntityPlayer npc)
{
for(Player p : Bukkit.getOnlinePlayers())
{
PlayerConnection c = ((CraftPlayer)p).getHandle().playerConnection;
c.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
c.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
c.sendPacket(new PacketPlayOutEntityHeadRotation(npc,(byte) (npc.yaw * 256/360)));
watcher = npc.getDataWatcher();
watcher.set(new DataWatcherObject<Byte>(16, DataWatcherRegistry.a), new Byte((byte) 127));
c.sendPacket(new PacketPlayOutEntityMetadata(npc.getId(), watcher, true));
}
}
public static void addjoinNPCPacket(Player p)
{
for(EntityPlayer npc : NPC)
{
PlayerConnection c = ((CraftPlayer)p).getHandle().playerConnection;
c.sendPacket(new PacketPlayOutEntityDestroy(npc.getId()));
c.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, npc));
}
}
public static List<EntityPlayer> getNPCs()
{
return NPC;
}
}
this was work in 1.16.5
but i do not have any idea to fix this
you're using nms, it'll break every version
can someone help me to fix this?
ik so i want to ask you guys about NMS
you need to change the imports
for ex what did npc.yaw change to
?
i alr change the import
b-but nothing change mean almost all of thing didn't change
at all
;-;.......... pls help this poor kid...... ;-;
does the method getBedSpawnLocation in Player get the spawn for respawn anchors? if not, how do I get the spawn?
i try many thing but not good way to fix this problem
also almost of thing that i was use is changed
playerConnetion is changed
mean PlayerConnection c = ((CraftPlayer)p).getHandle().playerConnection is changed
;-; help me
playerconnection?
Hi, im trying to access PacketPlayOutSpawnEntityLiving "a" field, how would i make it accessible?
if its a private you can only acces it in that class
yeah but is it possible to set it accessible
Reflection
have it public then
bro "public" makes it accessible anywhere you just do className.variable
yes but the one i want to access it private
.
.
Class.getDeclaredField("field").setAccessible(true)
so would i get the field from that class and set it accessable?
thanks
hey
how can i do something onevent after a command ?
i want to be able to freeze players
on /freeze player
how can I run something periodically while a player is online
runnables
but like how do I put a condition to runnables?
simply get the list of online players and run it for eeach of him
what condition do you mean
I was thinking while the player is online
like I can get if the player is online
but how do I make it so it stops if the player is not
well in the runnable you can check whether the player eaquals null, if he does hes ofline
how?
if (p == null) {return;}
no but like how do I use that in a runnable
wouldnt that just restart it
and not stop it
you mean stopping the runnable?
mhm
new BukkitRunnable() {
@Override
public void run() {
// things
if (Bukkit.getPlayer("iBoard") == null) cancel();
}
}.runTaskTimer(OrbRPG.getInstance(), 0, 20);```
smth like this?
idk what cancel does
but it seems to cancel the task
but im not sure if it just stops it for that run
or stops it completely
i think it stops completely
hey
i have an array list
and i want to remove player from it
and add player to it
i cant find how :(
List::remove
List::add?
wait that's a thing ?
Yuck, yes
No worries
no no no
uuid is a var i declared before
You need to call remove on the actual list instance
oh
if (args.length == 1){
Player target = Bukkit.getPlayerExact(args[0]);
if (target != null){
UUID uuid = target.getUniqueId();
if (freezed.contains(uuid)) {
List::remove(uuid);
}
else if (!(freezed.contains(uuid))) {
List.
}
else{
sender.sendMessage(utils.chat("&cPlayer not found or offline."));
}
}```
freezed.add(blah)
Itās not
Well
Method references can be used in certain places
But not with that syntax
so i replace List::remove(uuid);
by freezed.remove(uuid); ?
Yes
oh ok
freezed is a variable which contains your list object/instance
yeah
wait am stupid
lol
ok thank you it worked :D
š
now i'll add an onevent that checks player movement
and if player is on the list
it will cancel the event
š
good luck
don't cancel the move event
that's usually so buggy instead tp the player to their frozen location
cancel event ?
i'll try both since am still practicing
i've seen ppl say its buggy
i wanna see how it looks xD
if you cancel the event it will look buggy client side
i"ll test around and update on what works best
oh lol enjoy
i dont mind it looking kind of buggy
as they'll receive a message saying they are frozen
ty :D
yh its kinda annoying but try it yourself
and server side too btw
sometimes they can move
how do i set a custom item with metadata as an ingredient in a recipe without it giving this error
ok i'll just use the tp method
Could try to set player velocity to 0 no?
oh i thought it wouldnt since fro you to move serverside the event needs to not be cancelled
oh
try to turn off the players gravity
player.setWalkSpeed(0.0F);
you still should teleport the player btw
And give them potion jump to.
pls help
just to make sure
what
RecipeChoice.ExactChoice
teleporting the players is more respectful imo because in that case you can just not set the player speed back to something else because alot of servers Change the walk speed of players
uhh okay? how do i specify the item then
i mean teleporting will still look buggy client side
you can just save the walk speed to a var
nope
it really is kinda smooth
unlike cancelling the event
are you sure you're considering ping?
well you can do both
b1ab20aa-20ba-4715-baba-c7ada4b2df76:
Level: '1'
9fef0449-7993-4a16-9875-4b095d67d65d:
Level: '5'```
```for (String e : Main.instance.getConfig().getStringList("Players")) {
playerList.add(UUID.fromString(e));
levelList.add(Integer.valueOf(("Players." + e + ".Level")));```
tell me why this aint working
combine em
aight, like this?
recipe.setIngredient('R', new RecipeChoice.ExactChoice(rock));
mhm
k thx
you can do both teleporting and changing walk speed
but just cache the player walkspeed before anything
or just give speed 128
we really just started arguing about the best way to make a practise plugin
š
what is the name of this
?