#help-development
1 messages · Page 1692 of 1
Current code:
if (ghast.getPassengers().size() == 0) {
this.cancel();
}
Block block = p.getTargetBlock(120);
Location target = block.getLocation();
if (target == null) {
System.out.println("Target is null.");
return;
}
if (ghast.getPathfinder().findPath(target) == null) {
System.out.println("Path is null");
return;
}
ghast.getPathfinder().moveTo(ghast.getPathfinder().findPath(target));
System.out.println("Moving ghast to " + target);
Output:
Path is null
(disabling AI messes with pathfinder so I removed that)
Basically I'm trying to get the Ghast to move toward wherever the Player is looking.
(as if you're 'controlling' the ghast)
declaration: package: org.bukkit.conversations, class: Conversation
bump
k
Hey! Short question: I have created the following class to be able to insert something into my database table.:
private DataSourceProvider dataSource;
public Connection conn() {
dataSource = new DataSourceProvider(Main.getPlugin());
return dataSource.getConnection();
}
public boolean addPlayer(UUID uuid, String playername, int coins) {
try (Connection conn = conn(); PreparedStatement stmt = conn.prepareStatement("INSERT INTO playerdata (UUID, playername, coins) VALUES (?,?,?),")) {
stmt.setString(1, uuid.toString());
stmt.setString(2, playername);
stmt.setInt(3, coins);
return true;
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return false;
}```
Unfortunately, I can't call the addPlayer method in my desired location. Can anyone help me with this?
its not static
dumb dumb
?java
or create an instance of the class
call it from there
so if your class is called DataManager.java lets say
In your class where you're trying to access it, lets say SampleClass.java
public class SampleClass {
private DataManager data;
public SampleClass(DataManager data) {
dataManager = data;
}
}
And then access via dataManager.addPlayer()
or just Datamanager manager = new DataManager();
I'd do as PxL said
And then add a dataManager variable to your main class
and then access it through that
my thing id universal. u can ude it whenver u want. maybe not perfekt for this scenario
but works modt of the cases
modt
most
where exactly should I put this?
ok so i create a new class and create this Methods right?
u can put that everywhere
no classes extra needed
put it where u need
in the method as an example
Custom config files! Woo, save that data!
P.S I always pronounce "parser" wrong :(
------ Links ------
Download Eclipse: https://www.eclipse.org/downloads/packages/release/2019-03/r/eclipse-ide-java-developers
Download Spigot: https://getbukkit.org/download/spigot
Build Spigot: https://www.spigotmc.org/wiki/buildtools/
Starting Server up: ...
So basically
You have your main class (Main.java)
In your class (Example.java) have this code:
public class Example {
private Main main;
public Example(Main instance) {
main = instance;
}
}
and then in your code you can access methods from your main class
In your main class
DataManager data = new DataManager();
Example example = new Example(this);
Make a method like so:
public DataManager getDataManager() {
return this.data;
}
and on your Example class you can use:
main.getDataManager().whateverMethodYouWantHere
if this doesn't make sense you need to learn basic java.
(not a bad thing! we all start somewhere :D)
Of just private Main plugin = Main.getClass(Main.class);
Is it possible to get a list of biomes a player has been in? Sort of like the "Adventuring Time?" advancements, but I want to run my own action once a player has visited certain biomes.
How to make a tabcompleter for multiple arguments?
return a List depending on the length of args
Quick question is there a way with normal minecraft commands
To make a tool that can break any block instantly? Not like remove bur break (like instamine netherrack)
Or do i have to code smth up? (How hard would it be..?) I tried eff 100 netherite pick but dirt takes forever
Pls ping me
Alright and how do I make it look like when entering e.g. /give <Player> <Item> [<count>] etc.?
What? you return the appropriate list for whatever part of the command you are in (args.length)
Sorry for the bad sentence structure xD
I mean when you enter /give, it then suggests entering "<Player>" in greyish color. And in the tabcompleter it looks different
looks different?
Do you mean by the Example class the class with which I establish the connection to the database?
Hello?
Oh
Ah nah but then bormal breakkng is influenced too
I could use adventure but that mskes lore issues...
So prob custom plugin :(
I need to detect when user is clicking on a block and naturally break it...
Or amth along these lines
🙄
I recommend using Collections.addAll( for this
@copper dove ?
Any formula to convert seconds to ticks?
- 20
Thanks
if no server lag/load
is it possible for a plugin to act as a recieving webhook, or get external data to it in any other way?
awa
block.breakNaturally()
block.getLocation.dropItemNaturally(block.getDrops)
is there a way i can play a CUSTOM song/sound (nbs ofc) when my custom entity spawns
Sure. Plugins are still Java Applications. They can still open sockets, create connections, connect to databases etc etc
only example i know is when you summon a dragon in hypixel skyblock, it plays a song
For a new song you'd have to use a resource pack, otherwise you can do it by just combining all the current MC sounds and playing them as a song.
Doubt it. There's a lot of sounds at your disposal, especially with volume and pitch settings.
also combining all mc sounds is way too messy
It is, but you'll have to use a resourcepack if you want to avoid that.
so you think hypixel did it the dirty way?
Thanks, i will try arround... also need to give a custom item or smth... will figure it out, thanks !
If they made a song without requiring a resourcepack? Yep.
huh??
They do it all the time. What do you think the Housing Parkour music is? 
oh
they run a plugin
something like GMusic
but better
and also if they did that shiz manually, the plugin file would be like at 100mb
Nah, you can probably make an external file to house the song data and then the plugin just reads the file to know when to play what sound
lmfao
then the admin's patience is insane
OH WAIT
OR
add that gmusic thing
and when the boss spawns, play the music to the e.getPlayer()
with a command
Why a command
like
something like
runCommand (idk the thing) and then ("/gmusic play SONG_NAME " + e.getPlayer)
no?
you know the GMusic plugin right?
Yeah but I'm guessing it has an API for playing something to a player.
It's unlikely they're using GMusic anyways.
yeah they coded their own plugin
but a beginner can use GMusic
i will try with GMusic
for some reason i cant get a reference of my Main class
You probably want to have another reference then
use the this keyword in your Main class and pass it around as parameter of constructors of other classes
nevermind , i changed its name and it seems to work now
how can i make a specific task only run once
Already read the docs. There's nothing there that answers my question
runTaskLater
What?
cuz i currently use this method
for the task to run, but now that the testing has ended, i need to make it to run only once in the bosse's lifetime
Save the bosses uuid in a set after it runs and use contains
Or add a pdc tag after its run
Any efficient way to update a scoreboard?
You can just use an scheduleSyncRepeatingTask https://gist.github.com/securitygab/add855be527430e3849972df1e6e70a0
for who was that meant @quaint mantle
For Rayan sorry.
ah ok
i dont get reflections
public static void spawnAs(Player player, Location loc) {
EntityArmorStand stand = new EntityArmorStand(((CraftWorld)loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(stand);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
like how to do this
with reflections
A lot of getDeclaredMethod and class.forName
bruh can anyone spoonfeed me that ?
I mean I don’t think anyone will do that
You should consider doing research into reflection
Or using a module system
i realy dont get reflections
any way to change spigot api armor stand for each player without packets ?
Probably not
i realy dont get reflections
System.out.println("Spoonfeed");```
I generally don’t use it for NMS
Modules take a bit more time, but are easier to follow
Same.. reflections are breaking things,also a reason why it broke so much with the new java version
Now you get to used cursed unsafe
'Sytem.out.println("relate level: " + Relate.getLevel())'
oh
mobile hates codeblocks, plx forgiv
System.err.println("err")
Hey. I'm trying to use the ProtocolLib Play.Server.RECIPE_UPDATE packet, but without any luck. I haven't been able to find example usages of it, so I started looking for the structure which I'm supposed to construct the packet with.
Running java PacketContainer packet = new PacketContainer(PacketType.Play.Server.RECIPE_UPDATE); for (Field field : packet.getStructures().getFields()) { Bukkit.broadcastMessage(field.getAnnotatedType().toString()); } gives me java.util.List<net.minecraft.world.item.crafting.IRecipe<?>>, for which I find no structure modifiers except for .getAttributeCollectionModifier()
I am unsure how to serialise custom crafting recipes into this format
Hey how do I use an internal module as maven plugin
What I'm essentially trying to do is send stonecutter recipes ad-hoc as the player opens the GUI
which doesn't use the pluginRepositories repo
So then should I create the methods I create to insert something into my tables in the DataManager method?
So, i want to have a general idea of what im doing before making my plugin
How would i go about custom boats
Im thinking about just doing it the same as custom vehicles
But on water
But how would i go about making said custom vehicles, i know i have to use packets
But the only source code i could find to help me out used NMS
I wanna use protocollib
What’s the actual question?
How would i make a custom vehicle
Im not looking to be spoonfed code, just how i would go about doing it
@ivory sleet ok 😐
Use a lore. Main passenger is the player, secondary passenger is an invisible Armorstand.
The Armorstand has an ItemStack on it head that has a custom model and texture applied via the
custom model ID and a resourcepack.
And movement-wise?
Hi, is there a way to perform a bungee command from spigot API ? player#performCommand() googled around and couldn't find anything working.
ty i'll take a look
// C++ code to find
// duplicates in O(n) time
#include <bits/stdc++.h>
using namespace std;
// Function to print duplicates
void printRepeating(int arr[], int size)
{
int i;
cout << "The repeating elements are:" << endl;
for (i = 0; i < size; i++) {
if (arr[abs(arr[i])] >= 0)
arr[abs(arr[i])] = -arr[abs(arr[i])];
else
cout << abs(arr[i]) << " ";
}
}
// Driver Code
int main()
{
int arr[] = { 1, 2, 3, 1, 3, 6, 6 };
int arr_size = sizeof(arr) / sizeof(arr[0]);
printRepeating(arr, arr_size);
return 0;
}
// This code is contributed
// by Akanksha Rai
anyone have idea how this algorithm works (ignore the C++ language, this has nothing to do with it)? I cant seem to bend my brain how this works
why absolute values are the index value of another's index
i am trying to start coding spigot 1.8.8/1.8.9 plugins and after following a youtube tutorial to make a simple plugin that outputs a message to the console i got this error in the console and the message that was supposed to be outputted did not appear
can i send the error in a pastebin link for help?
yes you can
?paste
You need to compile with older java
You compiled the plugin with incompatible version of java for the server to run
You can change that in your build script or in the project settings of your ide
you compiled the plugin for the java version which your server doesnt use
for 1.8.8 you need to compile this with Java SE 1.8
or Java SE 1.7 iirc, but both versions are legacy versions, which are deprecated, so i'll choose the most recent one which you can use (1.8 supports lambdas and many optimizations)
when you're looking for unique values (which you need to know to remove the duplicate values), you need to store information about whether or not you have seen a certain value. You can either save that in a map somewhere else, with bitflags or what have you. In this case however, it's using the sign of the value at the number you're trying to check; if the number is negative it has already encountered it, otherwise it hasn't (and thus subsequently flips the sign at that location). it's important to note that this only works if (a) you only have positive numbers in the array and (b) that all the numbers are smaller than the length of your array
that's what I know myself, the thing is i cant seem to think why it uses this element arr[abs(arr[i])]
because arr[i] may be negative
since it may have its sign flipped because the number i was already seen
why abs(arr[i]) element value is used as an index for the array
all the numbers are smaller than the length of your array
that answers my question
arr[i] the value you want to check if it was already seen or not -> abs(arr[i]) because i may have been seen and thus the sign of arr[i] was flipped and you want the original number back
i did have a similar problem before when trying to setup the server using git and the solution i found was to delete the jdk 17 that was installed and it allowed me to create the server without problems though before coming to that solution i had searched for so long trying to find out where i can download java 1.8 and couldnt find a link or site to download it by searching on the oracle website and looking for java 1.8 download links on third party sites. do you know where i could find a download to it, sorry if this is a dumb question.
Is it possible to iterate over both online and offline players in one for loop?
I'm a slight java newbie, so i'm not sure
if you have a list of uuids you can just check if that player is online via getPlayer() method (i havent used spigot api in a while, i dont remember what the method is, lookup javadoc)
if you mean OfflinePlayer and Player types, these are derived from Player interfaces so they both could be iterated at the same time
I downloaded the Amazon Corretto JDK 8, will i have to change anything else or should the server and plugin work now?
change the build version inside project
you mean the other way around - a player is also an offline player, but not the other way around. the base one is offlineplayer
depending on your IDE
I use intellij
true
but i am not familiar with what you mean
do you use intellij build artifacts or other build system (eg. maven or gradle)
I use build artifacts, i dont actually know what maven or gradle really is.
To change the project structure settings, click the IDE and Project Settings button on the toolbar and select Project Structure the Project Structure button or select File | Project Structure (Ctrl+Alt+Shift+S) from the main menu.
there's option to select project sdk
change it to 1.8
that you've just downloaded
if it doesnt exist there, restart your ide
Ok
after that try to build the plugin once again
If you are online I got into something personal but I think the code you are looking for is java entity.getPersistentDataContainer().set(key, PersistentDataType.BYTE, 1);
When I hover over .set it shows this error The method set(NamespacedKey, PersistentDataType<T,Z>, Z) in the type PersistentDataContainer is not applicable for the arguments (NamespacedKey, PersistentDataType<Byte,Byte>, int)
Hello?
sorry it took me a bit to respond. i set the project structure sdk to the amazon corretto 1.8 jdk and after trying to build it said Error: java: invalid source release: 14
Cast the int to a byte
sorry, I still don't fully understand casting, so what do I do?
change 1 to 1b
got it!
b letter should make your number in byte type
oh yea
(byte) xxx
no
for(OfflinePlayer p : Bukkit.getOfflinePlayers()) {
p.getUniqueId();
}```
Seems to return online players to, is this normal?
when i run javac version in the command prompt it tells me that i am running javac 1.8.0_302
it returns the offline players from usercache.json file probably
Share the code?
that file has the UUID json map of all players joined in that server previously
?paste
PersistentDataContainer container = entity.getPersistentDataContainer().set(key, PersistentDataType.BYTE, (byte)1);
I see
and even in control panel programs it shows Java 8 Update 261 in the list of programs
offline player is the base for any player that is known to the server. an online player is also a kind of offline player. you can filter those out with !player.isOnline()
You need to store it in the variable and then call set with the variable
ohhhh
ahh
not runtime environment
if i uninstall the jre will it affect anything or should i download the java 8 jdk first then delete the jre
one runs things, other one runs and adds developer features, compilations, libs, etc.
you should have both
ok thanks i understand now
ok
the corretto one didnt seem to work so i am going to try AdoptOpenJDK
yeah its better to use adoptopenjdk since it doesnt rely on amazon dev team
but it works fine
please explain
.set() doesnt return persistentDataContainer
PersistentDataContainer container = entity.getPersistentDataContainer();
container.set(key, PersistentDataType.BYTE, (byte)1);
Ahh
.getPersistentDataContainer(); does
that way you store that in a variable and set the returned object via set method
is there a way to set a timer via the persistentDataContainer?
you can technically make .set() return the instance of the object but that's illegal in java conventions terminology. Unless you do some builder class
the only error that i got on both adoptopenjdk and amazoncorretto is Error: java: invalid source release: 14
check modules section
and check if the java version is correct there too
in project structures
Ok, I need to somehow get a variable from a different function, possible?
it is
k, how?
if function returns something yes
int returnedValue = function();
you really need to learn the basics of java first. that's not the insult, but necessity, there's no way you're gonna code spigot plugin if you don't know how methods and classes work properly in detail
the version in the modules is 1.8 aswell
I mixed up the words, also I thought a class was a .java file
.java file is the source code file, .class is bytecode compiled file
I mean this public void onRightClick(PlayerInteractEvent event) {
basically a class is technically translatable unit in the terms of .class files
even if you include multiple classes in one file. it would generate the same amount of .class files in the jar file as if you made them separately
I need to grab the container variable from an event so I can detect it in a different event
what's the event type
i havent used Spigot API in a while, but I remember a bit of it
what type of event do you have as an instance
the event I need the container variable from is PlayerInteractEvent and the one I need to detect to is EntityDamageByEntityEvent
BlockBreakEvent, EntityInteractEvent etc?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
what are you trying to achieve exactly in practical terms
I know it isn't supposed to be an insult but seriously I'm fed up with this
I am trying to detect if an entity was hit by an arrow spawned by a custom item, and if it is, make the damage it deals really high
When the arrow is shot
Add a tag to it
Actually no
When the arrow is shot just set its damage higher
how?
omfg, I haven't even thought about casting the arrow entitytype to my entity I'm so fcking stupid
that's limiting tho, because he couldnt do anything besides setting the damage
if you want to add message when the player is hit or some kind of custom event
you need to add some data
to store about the arrow
Thank you so much dovidas i really appreciate it it all works now!
np
this gives me an error ((Arrow) entity);
Are you gonna tell us anything else
Like, I don't know, the surrounding code
The error
sorry
lol
i just found out
that the trident
is technically an "arrow" in the game code
😂
Nice
error The left-hand side of an assignment must be a variable surrounding code Entity entity = player.getWorld().spawnEntity(player.getLocation(), EntityType.ARROW); ((Arrow) entity);
well
Arrow entity = player.getWorld().spawnEntity(player.getLocation(), EntityType.ARROW);
what about this
yeah
this worked for a fireball Entity entity = player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREBALL); ((Fireball) entity).setYield(10);
Yeah
Just casting doesn't do anything though
It's like if you just did
4;
What is the language supposed to do with that
You either call a method or set a variable to it
I also tried to do ((Arrow) entity).setDamage it threw the same error
casting returns the object in other data type thus why you should save it to the variable
else it would decay to nothing and will not be compiled, since it wouldnt be used and it would be useless
its like a function with a return value, but its not a function but it works similarly
Location location = ...;
final World world = location.getWorld();
final Fireball fireball = world.spawn(location, Fireball.class, ball -> ball.setYield(10F));
Its not a generic method. Passing the enum just returns an Entity.
Ah
please don't tell me I'm stupid but would this work Arrow entity = (Arrow) player.getWorld().spawnEntity(player.getLocation(), EntityType.ARROW);
prob not
but
also afaik interface Arrow wouldnt include spectral arrows
so if you want those you need to get AbstractArrow interface instead of Arrow
If you want the right type then just use the spawn method and pass the class.
Fireball fireball = world.spawn(location, Fireball.class);
And this one should be done using the launchProjectile method.
everything throws an error except Entity unless I add a cast like I did on this one
so this would work? java Location location = player.getLocation(); final World world = location.getWorld(); final Arrow entity = world.spawn(location, Arrow.class, ball -> ball.setDamage(10));
I should change the variables but
yes?
why this is not triggered when teleport cause is END_GATEAWAY:
public void onPlayerTeleportTp(PlayerTeleportEvent e) {
Bukkit.broadcastMessage(e.getCause() + "");
}
my theory would be that teleportation is not the same as entering the separate dimension since it would need much more to do for the Server to get you there vs just a simple teleportation
do you mean the end portal or that credits portal
now none of my events are working and there are no errors
also this method lacks @EventHandler annotation
yeah i have it but still not working
credits
Hello
I gtg soon
pls
Adding NMS EntityPlayer to server causes NPE
declaration: package: org.bukkit.event.player, class: PlayerPortalEvent
credits still counts as dimension portal still it teleports you back to overworld
but it derives from playerTeleportEvent
🤔
that's really interesting
How to check if a player have a specific potion effect?
if(response.transactionSuccess()){
String m = plugin.getConfig().getString("Settings.klaarmessage");
m.replace("%geld%", String.valueOf(amount));
this.p.sendMessage(Logger.color(m));
}
why does this still send: + %geld%?
did you google it
did you check the docs
declaration: package: org.bukkit.entity, interface: LivingEntity
#org.bukkit.entity.LivingEntity.getActivePotionEffects();
bruh
doesnt work too
yes i already told you it wouldnt. PlayerPortalEvent extends PlayerTeleport event
idk man sorry
replace doesn't alter the string, but returns a new string with replaced text
How to check if a player have a specific potion effect?
dude
...
We just told you
i want an example
if (player.hasPotionEffect(PotionEffectType.BAD_OMEN)) {
player.sendMessage("You have bad omen effect!");
}
Player p = ...;
if (p.hasPotionEffect(PotionEffectType.FAST_DIGGING)) {
// ...
}
PotionEffectType is an enum
oh i was trying the GetActiveEffects and then using .contains
how would i fix it then??
thx
that would work just fine but the has method could be faster since the array could be accessed more directly through craftentity class
anybody know how i can cancel runnable?
How can I rotate an armor stand's face and body to face EXACTLY where the player is facing?
you mean something like a scheduleDelayedSyncTask?
trigonometry
yes
well yes but could you give me an example?
you can get the taskID from the scheduling and cancel that outside the runnable
or are you trying to cancel it inside the runnable?
double rotationAngle = Math.atan2((playerX - targetX), (playerZ - targetZ));
Alrighty
I'll see if it works, thanks!
and actually, how would i implement the rotation angle?
anyone know how to stop TNT from blowing up items?
cancelling the explodeEvent doesnt work
@echo basalt
clear the explosion block list
doesnt that just clear the blocks that get destroyed in the explosion?
by well ... saving the result and sending that instead?
oh yeah right
try to hook entityevent
hm
and see what type causes the items to dissapear
Alrighty, thanks
what will the code be then
never worked with EntityEvent, will try it tho 😄
not just technically
and maybe the explode algorithm fires entity events
im not sure how to work with EntityEvent tho
oh its an abstract class
try to hook entitydeath or entitydamagebyentity
events
and see if your dropped items pop up there as an victims
well its not entityDamageByBlock since primed tnt is an entity
right
yeah I dont know how to continue from this
well cancel the event?
cant cancel that and I only want it to not disappear if the tnt that blows it up has a specific Scoreboardtag
you can do that or
which event ru using
I think the EntityDamageEvent would be better than the deathEvent
since you get a cause there
will do
EntityDamageEvent should work
no I think it needs EntityDamagedByEntityEvent since I have to have getters on the tnt that explodes
what for
since I have to check wether the tnt which blew up has a certain Scoreboardtag
why is the data not being written to the hashmap?
MessageManagers - https://hastebin.com/nerotijegu.csharp
TellCommand - https://hastebin.com/rudinesove.java
ReplyCommand - https://hastebin.com/jalojahoyo.java
if (e.getCause() != EntityDamageEvent.DamageCause.BLOCK_EXPLOSION
&& e.getCause() != EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) {
return;
}
@crimson terrace
there's no difference in results since EntityDamagedByEntityEvent extends EntityDamageEvent
since primetnt is the entity and item is an entity it should work just fine
not even sure what you were doing there
maybe im wrong
XD
well shreb it depends should all tnt not blow up items
or specific ones
?
the code i written above simply checks if the item was destroyed by an explosion
if not it returns
but this method only works if all Tnt should not blow up items
yeah hold on I almost got it i think
help pls
that might work, i would add a check wether or not the dropped item is an instanceof Item though
well I am checking if the entity is the type droppedItem
@sage dock i think its due to you creating a new MessageManagers class in your TellCommand, ReplyCommand
both have different Class instances
@crimson terrace can never be too certain :)
🤔
private final MessageManagers messageManagers = new MessageManagers(); you have this atop both classes
meaning they are different instances
you're creating new ones
You need to pass in the same instance for both
it does work 🙂
okey
Make a getter
it is in fact putting the values, in the wrong instance
show the code too
RarityGuiObject uncommonChest = (RarityGuiObject) new RarityGuiObject(Material.CHEST, ev -> {
}, Rarity.UNCOMMON).setName("&aLoot Crate").addLore(" ", "" + ChatColor.GREEN + ChatColor.BOLD + "UNCOMMON");```
thats code
imagine it without the cast
setName or addLore return GuiObject
oh yeah i think ur right
i forgot to change that with the extends
oh well lol its fine
wtf is this
Someone using the full path for DamageCause
why
Anyone know how to use DataWatchers in ≤1.8?
what
DataWatchers
That NMS status thing
In 1.8
All the documentation is for 1.9+
Anyone?
create it with the NMS entity
write the fields
and toss it into the metadata packet
And then to write
dataWatcher.a(id, value)
The accepted value types are these
@woeful crescent
What are the chances I could get someone to join VC and help me with an InventoryClickEvent?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!
just keep in mind that the event is called before the changes are made
Anyone know why Enchantment#getByKey is throwing a noSuchMethodError in version before 1.16?
Probably didn't exist
if it wasn't added yet what how would you get an enchantment from a string in pre 1.16
Probably still byName
It's deprecated, but it should
ok cool ig ill just have to deal with it being deprecated because i need it for my plugin to be compatible with older versions
unless there is a better way of storing an enchant in a pdc
Is there a way I can determine if 2 players are sleeping in a "double" bed ? Would iterate all sleeping players on the same time 1 block apart be a viable option ?
aww cute
😛
Moving vehicles with packets, how would I Gia bout doing that
And if it’s boats should I just use a boat rather than an armor stand?
How to I validate that a player is holding a banner?
I'm not satisfied with this. It feels hacky, but it works.
Object.getPlayer().getInventory().getItemInMainHand().getType().toString().contains("_BANNER")```
I feel like it should be something like:
```java
Object.getPlayer().getInventory().getItemInMainHand() instanceof Banner```
But this doesn't work and I don't think instanceof can apply to an ItemStack.
I also don't want to maintain a list of all of the types of banners. Any ideas?
…
I could replace contains() with endsWith()
…
Item instnaceof Banner
Since when?
This has been removed for a while
There are a ton of diff colors is the issues
OHHH it's getItemMeta?
ye
did you import the right banner
I'm using org.bukkit.block.Banner
declaration: package: org.bukkit.inventory.meta, interface: BannerMeta
org.bukkit.inventory.meta.BannerMeta
// If the player is holding a banner
if (!(playerMainHand.getItemMeta() instanceof BannerMeta))
throw new MassiveException().addMsg("<b>You must hold a banner in your hand to do this.");
Perfect, thank you so much! I have another application where I need to try a boat now lmao.
OK, so how would I apply this to a boat? I have a monster in the closet type thing that I should think about fixing now.
I tried doing the same as that except instance of boat btw
does anyone know of a spigot library that can accurately handle 3D rotations about arbitrary axes?
if not I guess I'll have to do it after all lmao
What are you rotating?
locations
Player locations?
no, Location objects.
It's just one set of 3D coordinates about another.
It doesn't actually have to be a Spigot library if I can just pass in the numbers and shade in the library, though.
I'm lazy and don't want to write a Quaternion class.
Gosh, maybe like Transform3D?
I'll look into it, one sec
yep, just found it haha
thanks though!
this might actually be extremely useful, if sort of tedious
it's more or less got the functionality I want
the main thing I'm having an issue with is rotation about arbitrary axes
I had to do this once for a client that wanted a demo of 3D modeling like 3 years ago
You need to do this regularly to ever feel comfortable doing this crap
and it's sort of hard to locate proper information on arbitrary axis rotations because every google result is all about matrix math LOL
like bruh I just want something relevant to this library
I'm familiar with vector/matrix math, but it's a LOT of boilerplate code
I'm a spring guy mostly. But I like hobby coding for this server.
thank you
the guide on setting up bungeecord plugin development on intellij is for 1.16
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.16-R0.5-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.16-R0.5-SNAPSHOT</version>
<type>javadoc</type>
<scope>provided</scope>
</dependency>```
where do i get the new information for the pom file
1.17-R0.X-Snapshot etc
the pom stuff doesnt work anymore, or at the very least, not for me
but where did they find the info for that in the first place
so i can input the latest values for <version> etc
thanks
hi
I made it so that blocks were placed 5 blocks away from me
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if(e.getItem().getType() != Material.STICK)
return;
if (e.getAction() != Action.RIGHT_CLICK_AIR)
return;
Block b = p.getTargetBlock(null, 5);
Location loc = b.getLocation();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
p.getWorld().getBlockAt(x, y, z).setType(Material.WOOD);
but if I click with a stick in the water, the blocks are placed in me. how can this be fixed? water is considered as an obstacle
I didn't understand. can I have an example, please?
how?
What version
1.12.2
I still didn't understand)
thanks
I still didn't understand anything
How to drop particles from the center of the block outwards, like a mini explosion?
radius?
force i assume
i forgor the particle methods
small
okay
Location loc = b.getLocation();
p.getWorld().createExplosion(loc, 1);
no
?
thats an explosion
not particles
I think he means with particles
instead of 1, you can choose a different explosion radius
no
I would like to make a mini particle explosion coming from the center of the block. It could be rocket particles for example.
particle 10.300 y?
how can i get this to work:
EulerAngle onePercent = givenlocation.subtract(arm).multiply(1d / time2);``` when i hover over (arm) i get this error in intellij ```Cannot resolve method 'subtract(org.bukkit.util.EulerAngle)'```, how can i fix this?
What is givenlocation
what
String locy = args[3];
String locz = args[4];
Location givenlocation = new Location(foundCrystal.getWorld(), Double.parseDouble(locx), Double.parseDouble(locy), Double.parseDouble(locz));```
subtracting does not accept an EulerAngle
so is there a way to subtract or?
water
You can;t subtract an EulerAngle from a Location.
ah ok thanks
hey there, i was wondering if there was a way to take the AsyncPlayerChatEvent and dispense a different message depending on the recipient
I know it provides a #setMessage option
setMessage and set the recipients
Not sure what else to do, I've already linked you a thread showing how to make a set
Set the recipients?
guys
Is that an option?
If you want to control who see's it
I didn't understand how to do this
I totally do, but
I don't see a setRecipients option here
just a getter
Correct
yes, you getRecipients then modify the collection
" The set returned is not guaranteed to be mutable and may auto-populate on access. Any listener accessing the returned set should be aware that it may reduce performance for a lazy set implementation.
Listeners should be aware that modifying the list may throw UnsupportedOperationException if the event caller provides an unmodifiable set."
is there anyway to divide multiply subtract or add EulerAngles?
Yes for add and subtract. If you want to multiply you are going to experience a whole heap of issues https://hub.spigotmc.org/javadocs/spigot/org/bukkit/util/EulerAngle.html
im trying to do double x = 0; EulerAngle originalRotation = foundCrystal.getLeftArmPose().add(x); and its saying 'add(double, double, double)' in 'org.bukkit.util.EulerAngle' cannot be applied to '(double)' ive tried int, float, string, and all that nothing is working (yes i know x = 0)
it requires THREE doubles
oh ;-;
how to spawn particle in center of block?
player.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, block.getLocation(), 30, 0, 0, 0, .3);
not spawning in center
Add 0.5 to the Location not the offset.
The offset would be 0.5 from the location, so if you want 0.5 from the center, add 0.5 to both the location AND the offset.
Any way to programmatically change a path name in a config?
wdym path name
oh rite
i imagine you would have to copy all teh data to a new key and remove the previous one
you mean
string: "s"
^^^
or
string: "s"
^^^
or anything else
cause i dont get what you mean
Is there any case in which the plugin will not catch InventoryClickEvent?
string: "s"
^^^
prob not
I have a GUI that should detect when you put specified item in it and then do things with it
But when i randomly place that item many times, there is a totally random point when it does not
no clue why
wdym?
Well i probably understood what happens. Sometimes you just accidentally hold the mouse button for too long and it makes InventoryDragEvent which i do not handle
just get the value
String s = config.getString("string");
then
config.set("string", null);
config.set("newstring", s);
i guess it works
Can someone pleas help me with this?
https://pastebin.com/s6hJDNHk
why is my permission not setting the right way? I can't find whats wrong. Its not working because my blockbreak event will be cancelled when i have not the permissions, it looks like this:
public class BreakBlockListener implements Listener {
@EventHandler
public void breakBlock(BlockBreakEvent e){
Player p = e.getPlayer();
if(!p.hasPermission("blockbreak")){
e.setCancelled(true);
Plugin.INSTANCE.log("test");
p.sendMessage(ChatColor.RED + "You don't have the permission to do that!");
}
}
}
it is the opposite ?
if you have the permission it will get broken
but if you dont it wouldnt ?
i dont get it
you want to cancel break
if someone doesnt have the permission ?
thats what they're doing
it is not working after i set the permission to a player.
try checking for perm "blockbreak.break"
dont just use blockbreak as a perm name
not entireley necessary
that code looks fine i think its just your Permissions stuff thats not properly assigning the perm
okay
it doesn't work i cant break a block with the permission
change
if(!p.hasPermission("blockbreak"))
to
if(!p.hasPermission("blockbreak.break"))
thats just a permission name it makes no difference
the problem is in setting the perms
yea but where are the problems in there? I don't get it whats wrong
How are you giving the player the permission?
With this:
attachments.setPermission(perms, true);
did you get teh attachment or create a new one?
im doing it like this:
public void setupPermissions(Player p){
UUID uuid = p.getUniqueId();
PermissionAttachment attachment = p.addAttachment(this);
this.playerPermissions.put(p.getUniqueId(),attachment);
PermissionAttachment attachments = this.playerPermissions.get(uuid);
String rank = PermissionConfig.INS.get("groups." + uuid + ".rank");
for(String perms : PermissionConfig.getConfiguration().getStringList("groups." + rank + ".rank")) {
log(perms + "");
attachments.setPermission(perms, true);
}
}
what does your log show for adding permissions?
the blockbreak.break permission
after you add all your permissions to the attachment try calling attachments.getPermissible().recalculatePermissions();
?paste your actual log where its adding the perms
here is the log
FishenJoe got the perm but the player who joined is BimEinsGamer?
however your log doesn't prefix so it it giving a perm of FishenJoe blockbreak.break?
FishenJoe is only a prefix i forgot to delete this. Ther shows nothing up from set permissions this is only the log
I made it so that blocks were placed 5 blocks away from me
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if(e.getItem().getType() != Material.STICK)
return;
if (e.getAction() != Action.RIGHT_CLICK_AIR)
return;
Block b = p.getTargetBlock(null, 5);
Location loc = b.getLocation();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
p.getWorld().getBlockAt(x, y, z).setType(Material.WOOD);
but if I click with a stick in the water, the blocks are placed in me. how can this be fixed? water is considered as an obstacle
I have a PDC in an event, and I need to check if an entity has that PDC in another event, specifically this one EntityDamageByEntityEvent. How would I do this?
the pdc is persistent ? Setting a value in it in one event will respectively allow you in another event to get or has that value
Citizens API:
- The skin I set is not working 😦
SkinTrait skin = this.npc.getTraitNullable(SkinTrait.class);
if (skin != null) skin.setSkinName(player.getName(), true);
- I want to make my NPC be targetted by mobs like a player does
My problem is first I don't know how to get my container variable from the other event, and second I don't know how to get my key?
why would you have a container variable ? The pdc is meant to attach data to an entity/tile entity/item stack
idk
passing your namespaced key around is another thing, you might be able to do that through normal dependency injection
e.g. as a constructor parameter
gtg
Show code

As the comment said why not merge them
As i said i have no idea
Then merge them
*no idea how to merge them
basic java
Gonna google time
Just add a second argument
It returning something weird, in my main i used this on enable
class1 = new KeepHotbarItems(this);
google "java multiple arg constructor"
Yep im trying to find the correct word lol
Debian11
You have more of a chance then
Well bluetooth is working. I just have no idea how to control it with Java or JS
I've never tried
I found the Eclipse Kura library docs are meh
Your using a 3rd party API or Oracles?
Oracle has none
It just has a standard it does not exist in the jdk
And the libraries that implement it are 10 years old or paid
guys
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if(e.getItem().getType() != Material.STICK)
return;
if (e.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
Block c = e.getClickedBlock();
Location loc = c.getLocation();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
p.getWorld().getBlockAt(x, y, z).setType(Material.WOOD);
e.setCancelled(true);
}
}
this puts blocks when I click on the stick
but it replaces the block with wood
So whats the problem?
how can I make the blocks be placed as usual without a stick?
what blocks?
I want that when you click on the stick, the blocks are placed as usual
how can I send a screenshot or video?
You are not making sense. Your last two statements directly contradict each other
when you click on a block with a stick, the blocks are replaced with wood. I need them not to be replaced, but to be put
put?
Currently you replace the hit block with wood. What do you want to happen?
so that it happens like a normal block that I put with my hand
so when you click with a stick you want a wooden block placed, as if you had placed it?
block = event.getClickedBlock().getRelative(event.getBlockFace());
then you just set that to Wood
I am trying to make a Water source Block to move away from me depends on where I am looking:
https://gist.github.com/ItzJustNico/74251085df59aafaf86872fed30fa599
But somehow it doesnt delete every block after it was Water and places the next one. And it looks like this:
https://ibb.co/rkf00zz
What did I do wrong?
I didn't understand. write more details
You are using startLocation.add This modifies the Location itself, so you are actually modifying it 3 times
I want to make a Water line where I am looking at. But I want to place one water block then place the next one and delete the first one. Then I place the third one and deleting the second. and so on
If you want to calculate a location clone it, or only add to it once
well, you can;t do that in a single for loop in a method without a timer
ahh wait let me try
it would all be done instantly and you'd only see teh final result
@eternal oxide
oh true
how do I pick up an item from the inventory?
yes
I don't understand what you want to do
pick up an item from the inventory
Not enough information
ah
no
write more details
I made a custom item which adds max health of a player
just a second
i want the item to be usable only once
like 1 item = 1 heart
but when players use item
the item dosent get destroyed
inven = p.getInventory();
slot = inven.first(Material.STICK);
item = inven.getItem(slot);
item.setAmount(item.getAmount() - 1);```
You may have to put the item back in the slot you got it from. Its been a while since I used an Inventory
that wasn;t for you
u pinged me???
oh sorry, wrong pping
now help me too
^ The code above is for you
this removes the item completely
please solve my problem too
that will remove 1 item from a stack
do you need to remove 1 item after using it?
are u saying me?
No, I checked, it removes the stack
That code will find the first stick in your inventory and remove 1 from the stack
p.getInventory().remove(Material.STICK);
removes all sticks from the inventory any number
hello, may i have your attention please madam?
Have you tried setting the Attribute for GENERIC_MAX_HEALTH to the ItemMeta?
Inventory i = p.getInventory();
int slot = i.first(Material.STICK);
ItemStack item = i.getItem(slot);
item.setAmount(item.getAmount() - 1);
`
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import smp.heart.heartsmp.items.ItemManager;
public class Heart implements Listener {
@EventHandler
public static void onRightClick(PlayerInteractEvent event){
if(event.getAction() == Action.RIGHT_CLICK_AIR) {
if(event.getItem() != null){
if(event.getItem().getItemMeta().equals(ItemManager.Heart.getItemMeta())){
Player player = event.getPlayer();
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(player.getHealth()+2);
player.getInventory().remove(Material.getMaterial("fragment"));
}
}
}
}
}
`
will take 1 stick from the inventory
please use code nlocks
do you need to pick up 1 item with a specific name and description?
me?
where is codenlocks google?
thats my custom material
So this line will do nothing player.getInventory().remove(Material.getMaterial("fragment"));
fragment is my custom item
Material is an enum, you can;t add Materials to it
i have defined material already
then use teh ItemStack reference for fragment
private static void fragment (){ ItemStack item = new ItemStack(Material.CARROT_ON_A_STICK, 1); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(ChatColor.RED + "Heart Fragment "); List<String> lore = new ArrayList<>(); lore.add(ChatColor.LIGHT_PURPLE + "Use four of these to craft a Heart!"); meta.setLore(lore); item.setItemMeta(meta); fragment = item;
can u send me the code please,
player.getInventory().remove(ItemManager.Heart);
ok
package test;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class ItemUtil implements Listener {
public static ItemStack item(Material material, int amount, byte data, String name, List<String> lore) {
ItemStack item = new ItemStack(material, amount, data);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
public static ItemStack item(Material material, String name) {
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
item.setItemMeta(meta);
return item;
}
}
or fragment, whatever its called that you are using
ItemUtil.item(Material.ACACIA_DOOR, 1, (byte) 0, "name", "lore");
"lore" is a string, not a List
new ArrayList({"lore"}) or something close
it only removes if there is only 1 item
if there is more than 1 in a slot
then it dosent remove
then you need to use similar code as I posted above for the Russian chap. you have to match using ItemStack#isSimilar
one sec
can u reply in that message pls
the item is always going to be in hand?
then just reduce the stack size
event.getItem().setAmount(event.getItem().getAmount() - 1)
not sure if getItem clones it though
eh i dont understand 😦
try that line, see if it works
wouldn't that just do ... nothing?
where do i add that line
yes sorry
thought as much hah
needs the -1
where do i add it though
you replace your current line where you try to remove the item
ok
can you offset the armor stand when it's riding a player?
i want to add 1 extra heart (increase max health) when players right click my "heart" item.. please can you tell me the command?
Can anyone help me fix a config file? I've been editing the config file essentialsX, and it keeps resetting, which is usually because of the fact that theres something wrong. can anyone have a look? x
oh i thought this counted as development 😅 sorry