#help-development
1 messages ยท Page 2213 of 1
i was seeing the code behind it
and started to print the things
then i realised that the boolean could do something
private void checkStyleAndColor(InventoryClickEvent event) {
StyleSelector newStyle = StyleSelector.getByName(event.getCurrentItem().getItemMeta().getDisplayName());
ColorSelector newColor = ColorSelector.getByName(event.getCurrentItem().getItemMeta().getDisplayName());
// If the item selected wasn't even a style (e.g. the background), do nothing
if (newStyle == null && newColor == null) {
return;
}
OutlinePane pane = (OutlinePane) getPane();
// remove enchant from previously selected color
pane.removeItem(pane.getItems().get(activeStyle.getItemIndex()));
pane.insertItem(HorseEditor.guiItem(activeStyle.getMaterial(), activeStyle.getName(), false, false), activeStyle.getItemIndex());
// add enchant to newly selected color
pane.removeItem(pane.getItems().get(newStyle.getItemIndex()));
pane.insertItem(HorseEditor.guiItem(newStyle.getMaterial(), SELECTED_TEXT + newStyle.getName(), false, true), newStyle.getItemIndex());
// save new color
if (newStyle != null){
activeStyle = newStyle;
getHorseInfo().setStyle(activeStyle.getHorseStyle());
} else {
activeColor = newColor;
getHorseInfo().setColor(activeColor.getHorseColor());
}
HumanEntity human = event.getWhoClicked();
if (human instanceof Player) {
Player player = (Player) human;
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
}
} ``` @ornate patio
even something like this, indenting is off cause just used a notepad ;p
anyways let me know if you need any help with any other packets or nms stuff
๐
damn thanks man ๐
although a few edits should be made
I really like the smooth slow up and down animation of the pufferfish.
https://gyazo.com/f514fc58602cc5d1a306d24566c77f34
I'd like to use this to display 3D models.
Is there any way I could make the pufferfish render as an item or make a helmet slot of the pufferfish render?
Don't worry, I've spent 3 hours today fixing a bug that wasn't there, as I realised that minecraft clients have this issue and relogging solves the problem ;p
bruh
Had a similar experience yesterday, I got desperate and decided to compile and load 50 times over and over and then it just worked
imagine
sometimes i reload while the file hasnt finished compiling
causing runtime errors
๐ค
same
basically when spawning an armorstand inside a block, it will sometimes remove the block that the armorstand got spawned at..... it actually doesn't remove the block on the server, and relogging the client helps....
damn wth
pane.removeItem(pane.getItems().get(activeStyle.getItemIndex()));
pane.insertItem(HorseEditor.guiItem(activeStyle.getMaterial(), activeStyle.getName(), false, false), activeStyle.getItemIndex());
// add enchant to newly selected color
pane.removeItem(pane.getItems().get(newStyle.getItemIndex()));
pane.insertItem(HorseEditor.guiItem(newStyle.getMaterial(), SELECTED_TEXT + newStyle.getName(), false, true), newStyle.getItemIndex());``` you could also split line 1-2 as a function, and 4-5 as a function/method
private void methodName(OutlinePane pane){}
ok so now i have a new issue
Anyone have any ideas?
have you tried the debugger?
@golden turret https://www.spigotmc.org/wiki/intellij-debug-your-plugin/
yes
it give me no errors
but simply
i dont have capes
and hats
the same problem i had before
Unfortunately I'm not much of help here as never messed around with nms or packets
@echo basalt you said i could let you know :D
np
only starting to develop anything for minecraft 2 months ago
yikes 2 months and you already know what packets are
respect
well, if you're a full stack engineer ;p
uhh
never spawned players through packets tbh
but huh
hmm
try
delaying the metadata packet
by 1 tick
usually fixes lots of issues
am I the only one that hates the bukkit scheduler
now i dont have even the player
nothing
wtf
okkkkkk
welp
let's start working on readability instead of fixing the issues
just for a second
make a method to send a packet to a player
๐
And some scheduler methods like runAsync and runIn1Tick
?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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
?ask Hello i need some help in pom.xml
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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
thanks babe
@echo basalt so, when i spawn im not sending the npc to te player. When i send the packet for the first time, it works fine and i send a destroy packet but when i send the npc the 2nd time, it dont work
yea
but
idk
i guess im seeing wrong things
because i did not touched the code
and it is working
say what you need
verify
oh god
?verify
lazy and i dont have time ;-;
so am I
got like 4 project to work on ๐ญ
man chill out
do Bukkit.getLogger.info(type.toLowerCase()); before the switch and see what you get
typical typo problem ;p
Bukkit.getLogger.Info is my go to if I don't get results I want
not sure what is your expectation of the yaw, but you want it to be 180 correct?
btw, I'm not 100% sure, but -179.999 might be in game value of -180
because there is 180 and -180
what should be in keys place???
your IDE tells you what type is expected as parameter there
straight up at a loss rn - why is it when i sit in my custom entity minecart (same code) i hold A/D and it will literally move sideways off the track
it's like the standard one resets the entity movement (the entity moves then cart snaps to it visually at least) but mine doesnt, but nowhere does that actually happen
How do you create regions
what regions?
Like to detect if a player gets in a certain area
cuboid regions?
ye
BoundingBox is a simple "region like" thing in bukkit
for example:
BoundingBox.of(firstBlock,otherBlock)
Ok thank you
it's not tied to any world though
Wdym
you have to check for the correct world yourself
Ok
it basically only stores X1, X2, Y1, Y2, Z1, Z2
so it would trigger event if its in the nether
then you can do stuff like isInside(Vector) etc
so the vector would be the boundbox variable?
no, the vector is the location you want to check
Example:
BoundingBox myRegion = BoundingBox(firstBlock, otherBlock);
now you want to check if player is inside that
then you do
Vector playerPosition = player.getLocation().toVector();
if(myRegion.contains(playerPosition)) {{ ... }
not sure if it's called "contains", but definitely sth like that
you can do that however you want. Every second, or in PlayerMoveEvent, ...
Which one would be more performance better
depends. Do you care whether it only detects a player entering after a second, or do you want to detect it on the exact same tick?
like "how precise does it have to be"
?
Doesn't matter, just the performance
then just run it once per second
you know, checking whether a player is inside is just extremely simple math
Ok thank you, ye I just wanted to know what "boundbox" was
basically all it checks is
- Is player's X > bounding minX and < bounding maxX
- Same for Y
- Same for Z
Thanks :)
declaration: package: org.bukkit.util, class: BoundingBox
How can I fix the error that intellij gives me, permission denied or something
Can't be bothered to check it for the millionth time
never had that error
where does it say that? in the gui? in the console?
or is it from the maven output?
Console
maven or "intellij console"?
It can't build the file
Because it doesn't have permission to build in the folder that it's assigned
then it probably doesn't have write access or cannot replcae or delete an existing file because you have it open somewhere
I also get this error when using cmd, visual studio or any other thing that needs access
How can I give it write access
no idea, maybe you created that directory as admin
No but like
IS THAT BOT DOWN AGIN?!
I go to my folder, in some locations when I try deleting a file it litearlly says I don't have permission lol
?paste
...
There a way to detect what items were shift clicked?
so there is no mangrove in TreeSpecies, is that intentional? trying to detect mangrove boats
probably just not added yet
Is it possible to force it to rain in the desert?
the animation is client side
So no, gotchya
you coud tell the client that it's actually another biome
but then also the color of leaves etc would look different
Yea it's all good I don't want to do that
That's probably bedrock
I meant the language bro ๐
c++
and english
^
๐ ๐ ๐ ๐
thats how ur mom laughs at ur jokes
is there a documentation for bedrock development?
Not even trying to be rude that has to be one of the worst jokes I've ever heard
Don't think so, bedrock is really weird when it comes to plugin development from what I can remember
You can try this
arent these basically mods
I believe so
yo alex, I think I'm having the same issue you were having way back like a year ago with luckperms. im trying to setup redis with it, no pass no user and im leaving both fields blank but its saying it cant get the resource pool. I was looking if anyone had the same issue in the lp disc and found you lol. idk if you remember how to fix it though
not a year, back in december mb
hmmm I don't remember having problems with that tbh - all I remember is that I had problems with "per-world" permissions while also using bungee, or sth similar
or per-server permissions
sth like that
can you send a link to my message?
maybe I then remember what the problem was
you didnt have a problem but it was kinda the same issue ish #241667244927483904 message
just curious how you got yours to work, im doing the same but its throwing an error
Uhm, does anyone know why this is happening and how I can fix it?
I have a chest that I put at this location, but when I compare they are just slightly off like so, so they aren't considered equal.
[STDOUT] CHEST ___ x: 85.0 y: 63.0 z: 15.0
[STDOUT] LOCATION ___ x: 85.02878949616395 y: 63.0 z: 15.117772265223364
location.getBlock.getLocation.equals(chest.getLocation)
do it like that
compare the block location
Ah ok thank you
np
oh yeah that was just a "general question" because I never used redis before
IIRC it instantly worked fine :/
interesting
i would try using setting a pass but idk how to update the redis password for pterodactyl so it crashes my web interface thing
oh you mean it maybe doesn't work because you don't have any password setup at all?
yeah yeah
because I definitely always used a password
yeah hm
you could try changing it and see if it works, then change it back to keep ptero working
then at least you know if "no password" is the problem
true, lemme see
didnt seem to work
sorry no idea. have you looked into the redis logs?
How do i know when to uncache data with redis?
And save to sql
Can i maybe use timestamps
they dont say anything errory
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player player && player.isOp()) {
if (args.length == 1) {
switch (args[0]) {
case "shockwave" -> {
Shockwave.play(player.getLocation());
Bukkit.getOnlinePlayers().forEach(p -> p.sendMessage("watch me whip"));
}
default -> {
player.sendMessage(ChatColor.RED + "Specified effect \"" + ChatColor.GOLD + args[0] + ChatColor.RED + "\" not found.");
return false;
}
}
player.sendMessage(ChatColor.GREEN + "Playing effect \"" + ChatColor.GOLD + args[0] + ChatColor.GREEN + "\".");
return true;
}
else player.sendMessage(ChatColor.RED + "Incorrect usage.");
}
return false;
}``` im not sure why the switch statement isn't being triggered
If I want to use EntityVillager, do I have to install spigot.jar???
who?
not who asked just like
who?
what are you tryna do
I want to extend the class to EntityVillager
is that nms?
Yes
Yes
you have nms in your project already ?
No.... I think
the Dependencies right???
yes
Nothing changed,
you reloaded maven?
yes
@winged anvil What you told me to do was right, I 'm just an idiot
shi i couldnt get it to work so im glad you did
were you able to extend EntityVillager tho?
cause my nms didnt let me for some reason
Yes
it says?
How???
https://paste.md-5.net/imaxipolom.cs
i dont get it, i followed a video and the only difference in our code was that his example event was in his main file while mine was in an events file, but i fixed it and now this.plugin is null which he (seemingly) didnt get as an error yes i am absolutely new to this file thing
holdup
yeah
send where you pass in the plugin instance at
probably in your onEnable() since i assume youre watching codedRed's video?
INDEED
yep 1s
@Override
public void onEnable() {
// Plugin startup logic
statsManPluginGrab = this;
this.SQL = new mySQL();
this.data = new SQLStatsHandler(this);
this.dataManager = new SkillsManager(this);```
right here?
yes
hmm
i mean you could try passing in statsManPluginGrab but its the same as just this
might as well try it tho
i cant see any reason why it would be null
would you like the whole main class?\
uh sure
be warned, you will need bleach, i have a lot of stuff from when i had just begun so some things are there which serve no real purpouse
idk where it could be null considering you have like 4 different instances of the plugin
i would just have ```java
public static ThunderLearn getInstance() {
return instance;
}
private static final ThunderLearn instance;
@Override
public void onEnable() {
instance = this;
}
lmfao
hold
yeah im aware i have a lot but i cant delete instance as its in use by a lot of my other classes
@quaint mantle this is what I do for my plugins (yes there are better ways to do it but I like this :|):
public static MyPlugin INSTANCE;
@Override
public void onLoad() {
INSTANCE = this;
}
@Override
public void onDisable() {
INSTANCE = null;
}
Then in my other classes I can use:
private final MyPlugin instance = MyPlugin.INSTANCE;
Boom, you're done! Now you can use your instance without any worry of it ever being null. You can also do it onEnable() but I usually prefer having it onLoad() just because there is no chance of anything loading before you get an instance of your plugin.
then i will do this if it works for ya
I made enderworld using WorldCreator, but there is no ender dragon and portal. is it just bug?
@EventHandler
public void join(PlayerJoinEvent e) {
if (!check(e.getPlayer())){
World source = Bukkit.getWorld("world_nether");
File sourceFolder = source.getWorldFolder();
copyWorld(sourceFolder, new File(Bukkit.getWorldContainer(), e.getPlayer().getUniqueId() + "_nether"));
World a = new WorldCreator(e.getPlayer().getUniqueId() + "_nether")
.environment(World.Environment.NETHER)
.generateStructures(true)
.createWorld();
Bukkit.getServer().getWorlds().add(a);
WorldCreator worldCreator = new WorldCreator(e.getPlayer().getUniqueId() + "_the_end");
worldCreator.environment(World.Environment.THE_END);
worldCreator.generator((ChunkGenerator) null);
World c = Bukkit.createWorld(worldCreator);
Bukkit.getServer().getWorlds().add(c);
}
push ๐ #help-development message
Anyone familiar with google guice?
whats your question
bind(SettlementService.class).to(SettlementServiceImpl.class).in(Singleton.class); (This is inside a the module configure function) I have created a singleton class out of my SettlementServiceImpl and I am not able to get a field with anywhere I want to get an instance of it.
im wondering guys
i want to store an block location in hashmap
and an integer
but not sure if storing Location in hashmap is a thing i should do
you can store int as key and location as value
Or if you really want to store the location as a key, you can create a method that returns a location with integer coordinates.
Why not
It depends on what you're doing
You can .get location from a map just fine if they have the same coordinates
if you arent holding anything
and i give you an apple
and then i ask for a banana
will you know that i actually want the apple?
yeah
(ReadyItem โ createReady)
Hiya! I want to make a plugin that I can post on spigot, problem is I only know mongodb and I need a db for the plugin to function properly. What other db language should I learn that everyone will have access to?
sql is common
well yea but what db? I was thinking h2
Don't you need to install a mysql server?
With h2 it's just a file
I'm not too sure
Alright I'll probably go with that, thank you.
Do you set the meta back onto the item?
What plugins do i need for exelentcrates to work
is it possible to make a passive entity fight using nms
how do i set and check perms for commands?
You can change the AI goals to make it attack things yes
Check is considerably easier, just Player#hasPermission
okee, thy โค๏ธ
i want to make villager fight but onky targetselector does not work so is there any gaol for fighting?
NMS is not exactly designed for you to play with, you may have to roll your own
Guys, do u think that this code is unreadable? https://paste.md-5.net/uxutoyavop.cs
oh
Define โnot workingโ
Nothing is unreadable, but that is very poorly formatted
what can I do for that? I'm new in java
Use an autoformatter
what is it?
intellij
Yeah IntelliJ has an autoformatter
You can customize it but the default one should work for you
How can I use it?
Why this calls PrepareItemCraftEvent ??
Doing something but not the right thing?
How do I remove / decrease amount of dispensed item by 1 from a dispenser even if the event is cancelled? (BlockDispenseEvent)
I have tried ((Dispenser) block.getState()).getInventory().removeItem(itemRem); but it doesn't affect the item in the dispenser if it has an amount of 2 or lower, even if the amount of itemRem is set to 1.
did it, nothing changed of my code ahah
aaa ?
Because the API was evidently designed to make it do so
You have to register every listener
Not just the plugin
can i cancel that?
Cancel what?
try ctrl alt L
to do not call that event when i'm removing my items
You can fork spigot if you want to
And remove that functionality
Other than that, no
I've coded this event a long time ago, but it was not like this
It may have changed
Or you might have a bug in your code and it isnโt doing what you think it is
That registers the listener in your plugin class
You have to register each listener individually
I think that there is a similar thing: if(that'sYourRecipe) e.setResult//setCancelled(false);
or just remove recipes from the server
They donโt want to cancel the event, they want to make it so that action doesnโt fire the event at all
ah
yeah u were right
I want to disable every recipe so
that will not disable the event from being called
You donโt put onEnable in each class, you just register the listeners
it'll hide the result of the recipe
doesn't matter now because i've removed the messages, now plugin just sets the recipe
@quaint mantle you have to register each instance of a Listener class that you wish to be able to handle events
Itโs the same method
It sounds like you need to spend some more time learning Java before trying to make plugins
Doing that through spigot is a mistake
Spigot requires a decent grasp of Java to really do anything
You donโt understand the object oriented programming structure enough to use the api
Yes, you need to learn Java properly before you start trying to do things with spigot. Spigot isnโt a language, itโs an API in Java. This is like trying to write a book in German before learning German
[10:04:05 WARN]: Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
[10:04:07 INFO]: Enabled in 2618 ms.
[10:04:07 INFO]: ===========================================```
Is it normal that it takes this long to start for the first time (with the folder already created)?
Itโs that legacy material support
Your plugin is forcing spigot to load a bunch of backwards compatibility stuff which is increasing your load time
include an api version in your plugin.yml
Does anyone know how to tell if an entity is inside of a Structure in 1.18.1-1.19?
@EventHandler
public void onDropItem(PlayerDropItemEvent e){
e.getPlayer().sendMessage(ChatColor.RED+"I'm sorry, you can't do this!");
e.setCancelled(true);
}```
Why not working :/
I want to when my dropped a item, it should set cancelled
And no have a error in the console
Btw I registered
That code will not throw any errors
Well, is it wrong?
Nothing wrong with it at all. I'm going to guess you didn;t register the Listener
@Override
public void onEnable(){
getServer().getPluginManager().registerEvents(this, this);
getServer().getPluginManager().registerEvents(new Perms(), this);
}
}``` It's my main
I think I did ๐
hey, i wanted to ask a question
is the only way to have vanilla-like weapon description with custom attack damage/speed is to add it manually via hiding the HIDE_ATTRIBUTES flag and ItemMeta#addLore() ?
are you getting the message
No
Then your plugin isn;t running
Bruh
I reloaded too much
I will restart the server
1 min
Oh
My plugin was working
But not now
Hey, I am trying to make a dispenser place blocks but for some reason the removeItem() method does not work when the block itemStacks have amount of 2 and under.
// the dispensed item
ItemStack dispensedItem = event.getItem();
Block block = event.getBlock();
// auto builder only uses blocks
if(!dispensedItem.getType().isBlock())
{
return;
}
if(event.getBlock().getBlockData() instanceof Directional)
{
event.setCancelled(true);
// the directional cast of the dispenser block
Directional dir = (Directional) event.getBlock().getBlockData();
// current location of the dispenser
Location currLoc = event.getBlock().getLocation();
// the location the dispenser is facing
Location targetLoc = currLoc.add(dir.getFacing().getModX(),
dir.getFacing().getModY(), dir.getFacing().getModZ());
// target location to place block has to be air
if (!targetLoc.getBlock().getType().equals(Material.AIR))
{
return;
}
// item to remove from the dispenser (same as dropped item but amount 1)
ItemStack itemRem = new ItemStack(dispensedItem);
itemRem.setAmount(1);
Inventory dispenserInv = ((Dispenser) block.getState()).getInventory();
dispenserInv.removeItem(itemRem);
targetLoc.getBlock().setType(event.getItem().getType());
I think that's the problem: https://paste.md-5.net/hacitojupu.java
I'm tryna get customskull by this... Idk how to fix, that's the only working method for me
I added some package here
Can this create a problem?
Check your server startup log for errors
"Best"
yea
Is this for me or Miche?
you
A very subjective question. Depends on your use case I guess
I'm tryna make an agency plug-in that stores Agency's employers name, balance and receipt number per day.
what can you suggest to me?
I checked but I couldn't found
But when me use /plugins, my plugin name is seems red
So it's disabled, check logs for errors. Elgar is right
That's what i'm talking about
My plugin is not even mentioned in the logs
When a plug-in is red is LOADED but disabled by the Server so the server printed an error line for sure
If thats all the data you need, then either can be used. Neither will be better than the other for something so simple.
If you think it's that simple, better config or database for it?
Oh okay
I did
Its writing: Plugin already initialized
Somewhere in your plugin you attempted to create a new instance of your plugin
you did new Main() or whatever your main class is called
From what you have described its more of a log than a databse
I don't think I've done anything like this
It's my main and don't writing something like new Main()
If not, you have two copies of your plugin jar in the plugins folder
This is not :/
madness..
Well, I donโt know... Iโm currently learning the use of databases, I wanted to know if it was convenient to use a database as I'll use this plug-in also as an API for the receipts plug-in that will update the value of receipts per day of the Agency & balance
Idk what to use rn
If it is to be used by just this plugin then go something like SQLite. If its going to be used across servers Mysql
was this the answer I was looking for! thanks! One last question if I may, sqlite can be only used for that plug-in because it is lighter than mysql?
no, its a file based sql on the local machine
Its memory based, but it stores to a single .db file on the local PC
at this point it wouldnโt become like a yaml config but with another extension?
kinda, but it has the features available of SQL and relational databases. search etyc
you get most of teh SQL syntax
Only main class can start as "public class Main extends JavaPlugin", right?
yes
Sorry again, last question, really ahah, at speed levels instead, better mysql or sqlite in this case in your opinion?
sqlite is simpler as you don't need any other install. Mysql requires a Mysql server. Both are memory based so speed will not be much different
no because I knew that the getString of a YAML for example, it took longer than one of mysql
Depends if the YAML is already loaded
If the file is already loaded the YAML will be quicker than Mysql
you made my day elgar thanks!
how can i delete attribute modifiers only for specific slot AND attribute, there is only #removeAttributeModifier(EquipmentSlot) and #removeAttributeModifier(Attribute) but no #removeAttributeModifier(EquipmentSlot, Attribute)
is it possible update the ender-chest animation?
instead of it continually being open?
๐ค ๐คจ
ok, also is there a way i can get the base value of any Attribute?
cool, thanks
((Lidded) chest.getState()).close()
probably
you may have to store teh state and call update() after
Thank you!
Is there an API for determining whether a player is cracked or premium on a cracked server.
Surely there must be a way somehow of externally authenticating a premium player
yeah but I want to determine between the two
I know premium players are given cracked uuids
Not in the API. the API is for premium only
well you could query Mojang
query their name and if the returned UUID does not match theirs they are cracked
but surely that applies to all players
all players have a cracked uuid
regardless of their account status
Is there a way to externally verify
before
When a player joins an online server, or via Bungee their UUID will be a valid Majang assigned one
Yes
that UUID will corespond to their player name
If the two don;t match they are cracked
?paste
To query Mojang https://paste.md-5.net/ebesunurap.java
?
yes but the server is cracked
hence all users uuids will be cracked
so there is no way of differentiating
?
I used build tools to build spigot and then I changed in the pom.xml file the artifactId to spigot but still can't extend class to entityvillager
I get this
NMS is obfuscated
I have already tried this
I tried both
Both remapped and "non-remapped"
I just did
copy the link it gives here
remove the minecraft-server dependency
When it's deobfuscated it's no longer entityvillager but just villager
You may want to make yoru pom easier to modify by adding in properties <project.spigotVersion>1.19-R0.1-SNAPSHOT</project.spigotVersion>
I removed it and nothing happened
I tried this to
are you sure you are using the NMS Villager?
also your updated pom https://paste.md-5.net/weriduleti.xml
you havent implemented the constructor
EntityVillager requires a constructor
in your constructor for Mob class you call super
like ```java
public class NewWarden extends Warden{
public NewWarden(Location location) {
super(EntityType.WARDEN, ((CraftWorld) location.getWorld()).getHandle());
}
}```
yeah
Villager probably only takes one arg of the ServerLevel (world)
its only Warden (new mob) that seems to require the EntityType
I 'm really confused
Why? Works for me```java
public class NewWarden extends Villager{
public NewWarden(Location location) {
super(EntityType.VILLAGER, ((CraftWorld) location.getWorld()).getHandle());
}
}```
I didn;t bother to rename
mine is 1.19 code though
requires an EntityType now
so for 1.18 its super(((CraftWorld) location.getWorld()).getHandle());
hm, shoudl be fine
I use 1.18.2
So should I try 1.19???
in 1.18.2```java
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.npc.Villager;
public class NewWarden extends Villager{
public NewWarden(Location location) {
super(EntityType.VILLAGER, ((CraftWorld) location.getWorld()).getHandle());
}
}```
works fine
Thank You so much
Finally, it took me months
I'd not done anythign with NMS and mobs till someone in here yesterday was having problems making a custom Warden
custom?
can we make custom mobs or items using spigot?
custom as in goals
can enums only implement and not extend?
yes
Thatโs because they already extend a class
Why i am only getting one attribute in atribute editor in nms package
right, makes sense
too bad it could've been useful to avoid to repeat boilerplate code in some enums of mine
interfaces are good enough
How can I cancel fire spread to specific blocks?
sometimes paper just sucks. How is the "UnusualXRepeatedCharacterHexFormat" in any way unusual? Like wtf, it's the spigot default builtin way for hex colors. it's the opposite of unusual
where's the problem of my plugin.yml? if i give someone postermaker.* permissions, the player doesn't gets postermaker.create or any of the others...
api-version: 1.19
description: Plugin to create Posters
commands:
poster:
description: Create a poster
usage: /poster
permissions:
postermaker.*:
description: permission for all postermaker dependent commands
children:
postermaker.create: true
postermaker.edit: true
postermaker.delete: true
postermaker.create:
description: create posters
default: op
postermaker.edit:
description: edit posters
default: op
postermaker.delete:
description: delete posters
default: op
Guys It giving tnt to all players Where is my mistake,
I see nothign wrong there
You are picking a random player each time but you are also looping over every player
Yes and you can just favor an easy composition design here
How Can I solve that problem?
are you tryign to pick a single player and give him TNT?
yep that's what i'm going for
weird, could it be a problem of luckyperms?
How are you checking they have the correct perm? Have you assigned the permission to each command?
jap, and not even luckyperms shows it...
why are you not assigning permissions to commands in the plugin.yml?
How can i prevent a person thats hidden for others have collisions with them?
uh, how does this works? ^^
add a permission line to each command
permission: postermaker.create:
you then don;t need to check in the onCommand
I created a vanish command but when i teleport to players i push them away.
Try ```java
public Player randomPlayer() {
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
if (players.isEmpty()) return null;
Player[] array = players.toArray(new Player[players.size()]);
return array[new Random().nextInt(array.length)];
}```
this what you need?
๐
i didnt saw :/
why are you calling a single player object 'players'?
cuz you are doing the objects.requirenonnull
as your ide said
null check instead
hey can anyone tell me which effect should i add when a mod spawn
means i dont know much about effects not even names
cuz its deprecated, meaning that you shouldnt use it anymore
go check the docs for what to use instead
ok
?jd-s
e.getItem will be null not the event itself
Again how can i disable Collison for one Player to all other entities?
Teams
I tried
Team team = p.getScoreboard().getTeam("Vanished"); team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
team.addEntry(p.getName());```
But that didn't worked
all players need to be on that team
or all players you don;t want to collide with eachother
I think
i guess hes talking bout players with other types of mobs
I think he posted earlier that he created a vanish but he pushes other players when he teleports to them
there is some LivingEntity#selCollision or smth but that didnt work for me
Vanished Player cant push all types of entities^^
That's what i want
Tried ingame with commands and it worked
Why I can't use World Server in 1.18???
oh, add the Player by UUID
team.addEntry(p.getName()); should at him?
or not. I forget if UUID is for player or mobs
better check for UUID
sec I'll check
Player
Can't use uuids there
you add Entities by UUID.toString(). Players are added by name
ooh learnt smth new
Can sb help me???
ServerLevel world = ((CraftWorld) location.getWorld()).getHandle();
Still this
if would be easier if you used code formatting in doscord than screnshots
Ok
Show me this in a code block
I don;t want to retype it all
public class NPC {
private static List<EntityPlayer> NPC = new ArrayList<EntityPlayer>();
public static void createNPC(Player player){
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
ServerLevel world = ((CraftWorld) player.getWorld()).getHandle();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "ANFFGaming");
EntityPlayer npc = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager());
}
}
and your imports?
Ok thx it works now
import com.mojang.authlib.GameProfile;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.EntityPlayer;
import net.minecraft.server.level.PlayerInteractManager;
import net.minecraft.server.level.ServerLevel;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class NPC {
private static List<EntityPlayer> NPC = new ArrayList<EntityPlayer>();
public static void createNPC(Player player){
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
ServerLevel world = ((CraftWorld) player.getWorld()).getHandle();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "ANFFGaming");
EntityPlayer npc = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager());
}
}
i see static abuse every single day lol
I found everything except for the PlayerInteractManager
Anyone knows how to check if an activator rail is powered?
if (railblock.getType().equals(Material.ACTIVATOR_RAIL) && railblock.isBlockPowered())
{
Bukkit.broadcastMessage("activated!");
}
for some reason railblock.isBlockPowered() returns false although it is powered. I am using VehicleMoveEvent to check if a minecart is above a powered activator rail.
railblock.getType().equals(Material.ACTIVATOR_RAIL returns true.
When i use
Team team = p.getScoreboard().getTeam("Vanished");
team.addEntry(p.getName());
It removes me from all other teams i'm in
Only when i use addEntry not by removeEntry
tryjava public void createNPC(Player player){ DedicatedServer server = ((CraftServer) Bukkit.getServer()).getServer(); ServerLevel world = ((CraftWorld) player.getWorld()).getHandle(); GameProfile gameProfile = new GameProfile(UUID.randomUUID(), ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "ANFFGaming"); ServerPlayer npc = new ServerPlayer(server, world, gameProfile, null); }
pure speculation as I've not tested it nor used any of this before
Elgar u have an idea why?
I thought you could only be in one Team at a time
No clue though as I've never tried to use more than one
Looks like you can be in multiple teams, but only on different Scoreboards
lol
Oh yes ๐ฆ
Hey, I would like to ask if there's any way I could do string subsitution (with RegEx or other methods) to substitute a value in the config on the fly.
Let's say I have this config file:
player-apples: 'Player has ${VALUE} apples'
How I may be able to subsitute that ${VALUE} with the amount of apples the player has?
Addendum; I have a function that retrieves the value, I'm just asking if in code I am able to subsitute it
Where can I download the 1.18 spigot api for eclipse?
I know the Graves plugin does this, maybe check out the code https://gitlab.com/ranull/minecraft/graves
Alright, thanks
Follow this tutorial https://www.spigotmc.org/wiki/creating-a-blank-spigot-plugin-in-eclipse/
and the spigot tutorial is shit too ๐ฆ
I asked where to find the spigot API not the tutorial on how to use it
This is the best start to finish creating a Plugin, other than his pom referencing a bukkit dependency https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse)
That will give you access to the API
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.11.0</version>
<scope>provided</scope>
</dependency>```
Can someone help me with linking api
Idk im doing wrong
I thought minimessage was included in paper now
it is
I only use Spigot so can't advise
@Override can be only in the main class?
๐
No the annotation should be present on any method that overrides a method from a parent class
override is used anywhere in a subclass that you want to override one in the parent
In your Main you are overriding methods which exist in JavaPlugin or higher
So can't it be found at the parent ๐
Its not a requirement to work, it simply makes checking your code/implementation easier
use the lp api
otherwise check if the code even runs
i dont really know the luckperms commands so idk if there would be an error in the command
also i think this will override their current rank, you would probably want to use parent add
yep, it is parent add
What is the most efficient way of restoring an arena where you can place blocks every once in a while ?
Because I made a plugin that does that but it's very ressource intensive
Aye guys, lemme ask another custom item question =]
So I have registered about 10 different NamespacedKeys for 10 different items. Now I want to be able to check WHICH item the player has before performing an action. Is the easiest way to literally just have a bunch of if(meta.getPersistenceDataContainer().Contains(key) -> do this item logic, proceed to next if? There has to be a easier way right?
Why not use the LuckPermsAPI?
Hello! I'm trying to replace the drops with something else, how do I do that?
public void onOreBreak(BlockBreakEvent event){
Block block = event.getBlock();
if(block.getType() == Material.DIAMOND_ORE){
event.getPlayer().sendMessage("Daarin! Will you get me a diamond ring?");
}
}```
A map?
A map of what though? I have a map of namespaced key to some item specific stuff, but I still need to iterate through every namespaced key on the object and check if its contained in the map
I guess let me ask this, this would probably solve it
given an item, is there a way to get the namespaced key of the recipe that was used to create it? I have combed through ItemMeta and ItemStack and I don't tthink theres a way
No, item stacks don't know the recipe used to craft them
Unless you manually attach it in the PDC
Hmmmm, scratching my head on this one haha
Generally,the way to go is one single key
And the value is the type of item
Like yourpluginname:itemtype as key
And then ehh "superdupersword" as weapon
I think that is how im gonna do it, somebody suggested to me yesterday to work with the namespaced keys rather than raw strings as "item identifiers"
Then you just always grab the value and do a lookup through some map/index
but just having a simple string that has a "id" basically
seems to be the best way =]
I mean, nothing stopping you from using a namespaced key as a value either
Just write your own data type
Thats a fair point ๐ฎ
Sorry for the rapid fire questions lol one more
When you register namespaced keys for custom items, do you even bother keeping a reference to them?
If im not using them primarily for identification, I don't think I really need them anymore after recipe creation
The namespaced key instance?
yup, like can I just make a new namespaced key and just let that baby fall out of scope
or should I hold onto these keys for some reason im unaware of yet ๐
Yea you can. But if you go with a single namespaced key for identification and use the value as the item identification this question is mood
So I do notice that I am not able to use the same namepaced key for multiple items, thats why I ask
Hm ?
I have like 10 namespaced keys, but then im gonna have one namespaced key for holding the "item type" that will be common to all of them
when creating a recipe it wants a unique key
and if I try and reuse them it complains about duplicate recipes
awesome ty =] im learning the spigot api slowly haha
I'm searching for a SkullUtils to get a custom head from the customheads site with the head's value, I found that CryptoMorin's util https://github.com/CryptoMorin/XSeries/blob/master/src/main/java/com/cryptomorin/xseries/SkullUtils.java
but idk how to get custom heads with that value, can you help me?
Does anyone know why seeFriendlyInvisibles true isn't working with sscoreboard?
Can someone help me with making a GUI user specific?
I have a GUI that modify items dynamically with user specifics infos but it changes the GUI for everyone in it
create a new gui
yea but what's about the event listener ?
do i need to create an event dispatcher ?
can someone help me with this?
i don't have to register it in the plugin main ?
(1.7.10)
legacy plugin maintenance
it depends how your gui system is setup
i for example have 1 listener for all my menus
same
so an event dispatcher
it get the event
filter with a gui list
and done ?
have an InventoryClickEvent -> see if clicked inv is your custom inv -> perform actions
hey im trying to add custom recipes and I made a ShapedRecipe and added it thru bukkit but when I take things out of the ingredients slots when crafting the result shows up when there is nothing in there
so you put the ingredients inside the crafting bench, then you take them out and the result is still there?
you are messing with the craft event to put a modified result
more specifically any ingredients
that would be my only explaination as well yea
im not messing with the event im doing
Bukkit.getServer().addRecipe(shapedRecipe);
that on its own will not produce the effect you are seeing
unless its a bug on 1.19 but i very much doubt it
im on 1.19 but ig ill test on 1.18
How ridicolously cheap have websites become
eh depends on the domain you want
well I just got a .com domain for 2โฌ a month lol
Way overpaid there lol
yea
i get them for 5-12โฌ
Just the domain or anything else included?
domain
ah yeah that explains it
I can get one for a year at 6 euro
I've got webhosting and some other stuff included I guess
webhosting 2โฌ
SSL 5โฌ
a year?
thats not bad
so they say ๐
i have one listener for every gui instance ๐คก
yea. who doesnt..
on namecheap 5.98โฌ/1 year for .com with 4.71โฌ/1 year SSL and optional webhosting for either per month or year
When did websites become so cheap
It's always cheap
damn
it just becomes expensive when it comes to making your own website
or even worse, forum
host your own on a NUC or Pie
How do you copy a structure with spigot in 1.18 do you just have to change the blockData of each block ?
wdym by structure
like a village house?
or just a region between 2 points
when the player selects 2 points, he should do something to copy it.
use the player as origin
then map relative points to blockdata
with player location as origin
use the StructureManager https://hub.spigotmc.org/javadocs/spigot/org/bukkit/structure/StructureManager.html
StructureManager sm = Server.getStructureManager();
Structure newStructure = sm.createStructure();
newStructure.fill(Location, Location, true);
sm.saveStructure(File, newStructure);```
or you can create a NamespacedKey and register teh Structure to use it
Origin I would guess is the center
ah
but could be the first Location
so you cant specify the origin?
thats for copying to the Structure Object
i c
can anyone gimme some feedback on a design choice? I don't like it that much but i can't think of anything else
i've made an enum with these constants as a configuration for different armor tiers
i also have other enums similar to this one for pickaxes and weapons and i was wondering if I should merge them into a single one instead of using ICosmicMaterial as an identifier interface
the issue is that pickaxes have some slight differences compared to weapons and weapons are a bit different compared to armor
ex. pickaxes are indestructible but armor and weps are not, so I have to config durability for armor and weps
i think this is not that bad if its for personal use/a client.
it's a private plugin and it's not meant to be edited
then i think this is pretty acceptable.
aight thanks
How can I damage a player naturally ? like some zombie has attacked him
command not registered?
Not a CommandExecutor?
command not in plugin.yml
add @Override to the method and see that it doesn;t give you a warning
Hey guys, I want to get the face of a water block the player right clicked on. I have to use getLineOfSight() because water/lava doesnt register as a RIGHT_CLICK_BLOCK action. Normally I would use event.getClickedBlock().getRelative(event.getBlockFace()), but like I said water and lava dont count as a clicked block. Is there a way to determine what liquid face they clicked?
I could do some trig to determine the closest face, but that may not be where they placed it
raytrace to the block
hmm looking into it now
it has fluid collision
ah yup this returns a block face in the ray trace results, I think this will do =]
is there an event listener that gets fired whenever a player moves around items in their inventory
InventoryClickEvent
and drag
oooh i was searching for player something, thank you!
your class is not a CommandExecutor
Thats a Listener class. No CommandExecutor
Thats why we use @Override ๐
Tells you instantly there is no method to override so your parent is wrong
wait i ran into another problem now
how do i like get the player who clicked in their inventory
my motive here is to give the player an effect whenever they click in their inventory but i don't know how to do that with InventoryClickEvent since i can't seem to getPlayer on it
getWhoClicked()
got it, tysm!
sorry , but why am i getting an error here? bit new to developing plugins so i apologize for the endless questions
cast it
add (Player)
it returns a HumanEntity
^
but im not rlly aware of a case where it will not be a player
Player player = (Player) event.getWhoClicked();
could check if its an instanceof player if you want. its probably not needed, but idk
javadocs: Gets the player who performed the click.
idk why its not just returning a player
wait so does adding (Player) in front of the event.getWhoClicked() cast it from HumanEntity to Player?
yes
When you get errors, hover on the error (or the red line) and it will show you why that happens.
Saves you and us time (not to be rude, just want to help :D)
are u returning false or true?
did you extend CommandExecutor?
What's the point of the command name check seems redundant
did you add the command inside onEnable?
extend CommandExecutor and register it
Can u show your code
so many people do this, never understood why
YouTube tutorial somewhere I'd assume
show us onEnable
there is no point in checking the command name
Is there a way to change the behaviour of operators in java like c#? (e.g https://github.com/Unity-Technologies/UnityCsReference/blob/master/Runtime/Export/Math/Vector3.cs#L444)
can anyone tell me what the point of having HumanEntity in the first place is if Player is the only thing that uses it?
no, only if you use something like kotlin
I dont think player is the only one
but i m not sure
maybe its for forks of spigot? \o/
Ty!
you need to register both
no
that is for events as it says
this.getCommand("mhhunter").setExecutor(new HunterCommand());
this.getCommand("yourCommandNameFromYourYAML").setExecutor(new HunterCommand));
u are fast
and you do not need to register listeners if you did not use one
yes only use register events when ur class has implements Listener
make a hashmap which stores players and booleans
if the boolean is true, make the player the god else dont
Is there a quick way to check if a player has room for an item in their inventory without having to loop through their inventory contents?
declaration: package: org.bukkit.inventory, interface: Inventory
is there any way to tell who placed a boat? my best guess right now is tracking right clicking with a boat in hand and checking that against VehicleCreateEvent but yuck, that can't account for situations where spawn fails
What about if it is a stackable item where there is no empty slots, but they have room cause of a stack?
u can fist check if it contains your item
Hey, is there an way to send the whole console output live to the ingame chat ? want to code an ingame console plugin
if it does, use Inventory#all(ItemStack)
and u gotta check all those stacks
oh yeah
it does
i always forget that
Btw what is the new way of setting player's max health cause it says Player#setMaxHealth() is deprecated.
Ah.
or add a modifier, if you don't want to alter the base