#help-development
1 messages · Page 1383 of 1
I guess it's because of the tnt.setFuseTicks(0); to process
But when using World.createExplosion(), it only triggers EntityDamageEvent, so I have no idea how to get back the shooter from there.
You cant. The explosion is the damage cause which cant really have a cause on its own because it originates from a Block (when the world method is called at least) which can not be a damager.
in 1.13+ There are methods for creating an explosion with a primed tnt that does not pop up for one tick. This could
be used to track back the origin of the arrow. But you are on a very old version so i guess you dont have that luxury.
yea please update
lmao
we don't know what shit is going down over there in 1.8 land
Alright, the land in kinda ugly stay up there x) I have not made any custom entity yet, but would it be possible to create one just like primed tnt which has an initial fuse tick of 0 ?
We get a lot of questions in here for 1.8 when only 6% of servers run 1.8
How can I reload plugins while the server is active
Sure. If you want to dive into nms for that...
boomers having a hardtime getting used with 1.8+ uh
yeah we wont help you with that lmao
no its not about a hard time, its about that you are using a version that is years old
Alright I guess I'll keep that pretty tnt, not that bad finally x) thanks for your help
I'm playing minecraft since a long time and I can"t get used to 2 arms, shield, things to fly ect...
thats your fault lmao
My boy we have played minecraft when you probably weren't even born. We know what trash looks like when we see it.
And 1.8 is way up on the trash scale. All we see are angry kids that like to hammer their left mouse button down there.
and most of us aint boomers either xD
stop using 1.8 lol
22y and still beeing part of thoses kid, what a sad life :feelsbadman:
talking about me 😦
You need to delete the old world or else it will just load it.
Ok glhf
This shouldnt even compile
Sure I get it, that's fair, I got the answer I was looking for that's cool
Just add 1.8pvp in 1.16 ver
nvm. But you need to
- Unload the world
- Wait until its completely unloaded
- delete the folder
Tbf that doesn’t solve it.
it can;t delete files that are in use
What do you think it means? Did you read any of it?
I'm having a regex error, can anyone help? This is my regex: \b*(?<!\\)
This is the error:
A ChatColor's name would go after the regex, such as GREEN
escape for java
This is kind of ugly but it should work:
public CompletableFuture<Void> unloadWorldAndDeleteFolder(final World world) {
File worldFolder = world.getWorldFolder();
return unloadWorld(world).thenRun(worldFolder::delete);
}
public CompletableFuture<Void> unloadWorld(final World world) {
final UUID worldID = world.getUID();
Bukkit.unloadWorld(world, true);
return CompletableFuture.runAsync(() -> {
while (Bukkit.getWorld(worldID) != null) {
try {
Thread.sleep(100);
} catch (final InterruptedException e) {
e.printStackTrace();
}
}
});
}
yeah, which one? I tried doing the first one, it didn't work
I've already escaped the second one, as you can see
Didn;t we do all this yesterday?
colour replacing enum color names unless prefixed by \
Yeah, we did (not yesterday though), and it worked. But now it's not working for some reason
Yep
it was workgin I gave you working regex
so how do you have a broken regex now?
How can I find the item a player is holding
I'm not sure
And if you want to block the main thread until all that is done:
public void unloadWorldAndDeleteFolderBlocking(World world) {
unloadWorldAndDeleteFolder(world).join();
}
But i would use the CompletableFuture to run something on the main thread afterwards like this:
public void unloadAndDeleteWorldThenRunSync(final World world, final JavaPlugin plugin, final Runnable runnable) {
this.unloadWorldAndDeleteFolder(world).thenRun(() -> Bukkit.getScheduler().runTask(plugin, runnable));
}
Runnable is just a simple interface from Java. If you have used the BukkitScheduler before (properly) then you should have implemented that
interface at least once.
So you can pass a lambda there or any class that implements Runnable
And the run method will be executed later
I think unloading the world should return a CompletableFuture anyways...
@eternal oxide, never mind, I figured out what was happening. It was a different usage of replaceAll()
Would this make tnt spawn whenever somebody right clicks:
@EventHandler(priority= EventPriority.HIGH)
public void onPlayerUse(PlayerInteractEvent event){
Player player = event.getPlayer();
player.sendMessage("Clicking");
Entity r = player.getWorld().spawn(player.getLocation(), TNTPrimed.class);
r.setVelocity(new Vector(0, -1, 0));
}```
Because you are currently doing unloading and deletion async. And this lets you sync back with the main thread.
um, thats going to spawn and then fall into the floor
Ok
public Resource(Plugin plugin, String name) {
if (file == null) {
file = new File(plugin.getDataFolder(), name);
}
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
if (!file.exists()) {
plugin.saveResource(name, true);
}
}
This is how I load my custom yml File. The Only thing is is that it even if the file has been loaded before, if will reload the file again setting it back to the default settings. Any clue what I need to add to my code to make it not reload if the file is already present?
Btw you should use the method that takes a Consumer<T> as third argument to change entity
parameter before it spawns.
save if you make changes
is your player actually interacting with something to trigger the event?
and is he getting the click message?
yes and no
They are interacting but not getting the message
then you are not interacting with anything, or you didn;t register the listener
The changes I'm making is from the file not the code.
Help development français??
then performing a load will make no difference. the load will pull in the file complete
Nope
pas ici dsl
ok
In the same regard as Hypixel Skyblock, how could I make multiple items that have different Server-side ids but not client side
Store an id in the persistent data container
Didn;t you ask this earlier today?
oh yeh lol
ok
code?
Something in PrivateVailt.java line 51 is null
object is null
So there is no PlayerVaultObject for that UUID present at the time you access the map
There is no best way. But generating them on a grid with fixed X and Z distances would be my first approach
It also depends on if each player should have its own world or server. Then i would try a docker approach.
How can I get the tags of an item?
How can I get the tags of an item?
@novel lodge are you using pdc?
Define "tags"
You can tag an ItemStack by using the PersistentDataContainer
How do I get the itemstack of the mainhand item?
nevermind
player -> getInventory -> getItemInMainHand
How do I get the persistent data container then?
From the itemmeta
I can't find any way to get the tags
getItemMeta.getPersitantDataContainer.get
Set<T> originalData = new HashSet<>(this.originalData);
Set<T> currentData = new HashSet<>(data);
originalData.removeAll(currentData);
I want to get the differences between an list, but this just returns me an empty "originalData" list. Like list A: (a, c, e) and list B: (d, c, e) -> I want to get (a, d), and not c of e
I use it in my plugin and works very good!
not without NMS
public <T> Set<T> getDifference(final Set<T> original, final Set<T> data) {
final Set<T> smaller = new HashSet<>(original.size() < data.size() ? original : data);
final Set<T> bigger = new HashSet<>(original.size() > data.size() ? original : data);
bigger.removeAll(smaller);
return bigger;
}
Thanks
Get the nms ItemStack and tinker with the NBTCompounds.
I believe there were several third party apis for it you could look at
^
nono:
public Map<String, ItemStack[]> getplayervault(){
return playervault;
}
Never expose your data strcutures. @humble heath
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
it is in there already
I dont understand this class. It looks quite obsolete to me
Where does the Map<> thats passed in the constructor come from?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
does anyone know why getting a string from the config.yml returns null?
this is the string im trying to get, game-start: "&bA game has started!"
and this is the method im trying to get it with:
String message = plugin.getConfig().getString("game-start");
return message;
}```
print plugin.getConfig().saveAsString(); and see if it appears
ok
you mean like System.out.println(plugin.getConfig().saveAsString()) ?
@fading lake
yes
Maybe it’s on YamlConfiguration
sorry its saveToString not saveAsString
throw the contents in chat
Gamemode: default
[13:11:20] [Server thread/INFO]: Custom-world: false
[13:11:20] [Server thread/INFO]: Time-limit: 5m
[13:11:20] [Server thread/INFO]: Playing-players: all
[13:11:20] [Server thread/INFO]: no-permission: '&cYou do not have permission to use this command!'
[13:11:20] [Server thread/INFO]: game-start: '&bA game of tag has started!'
[13:11:20] [Server thread/INFO]: chosen-it: '&e&lYou &r&ehave been chosen to be it! Try to catch other players.'
[13:11:20] [Server thread/INFO]: chosen-it-everyone: '&e&l%player% &r&eis it! Avoid him at all costs!'
[13:11:20] [Server thread/INFO]: been-tagged: '&eYou have been tagged by &l%player%&r&e! You are now it!'
[13:11:20] [Server thread/INFO]: been-tagged-everyone: '&e&l%player% &r&ehas tagged &l%tagged-player%&r&e! Try to avoid
[13:11:20] [Server thread/INFO]: &l%tagged-player% &r&eat all costs!'
huh thats odd, when is getStartMessage() called?
when i do a command
how peculier 🤔
👀
yea all the other messages worked so idk whats wrong with "game-start"
Doesn’t work or what?
and you're trying to get it with the same static method?
M1norDragon how do you load the config an
I think thats the default one
d do you change it’s content anywhere
@ebon shoal
Yeah well this is most likely a pebkac issue
?
is there a way to disable the vanilla advancements in the code
no, not the same method
each message has its own method
Why is this not working ? player.teleport(spawnX, 108, spawnZ)
create a new location Location loc = new Location(x, y, z, yaw, pitch); and player.teleport(loc);
try that
thanks
how cash Chunk to PlayerChunk?
any idea on my issuer
it's what you call a bad wrapper to a map
ok but i realy need to fix this issue
How can I prevent the PlayerInteractEvent from being canceled but the player still being able to eat?
Cancel it and then proceed to uncancel it at monitor priority, though that may still get processed by some plugins
there's a method actually
not the cancel one
useitem
or something
check out the event
tho i don't believe it's in the api
I have no idea how to go ahead now
can some one help me plz
a
?
Bukkit.getLogger().info(String.valueOf(val));
how can you get a random number? i tried that and it always returns false
i really dont get it
int number = new Random().nextInt(25); ?
Random random = new Random();
if (random.nextInt(2) == 0) { // 50% chance
}
int randomInt = random.nextInt(30); // Random number from 0 to 29
@sharp bough
im gonna try this one
since a 50 50 chance is what i need
didnt know if that was 50/50
3 sided coin
There is a random.nextBoolean you know
did you mean to do random.nextInt() % 2 == 0 ?
Please read
no
0.25 or just use a nextint then
no
i'll just ban u if it hits that
I don't remember being taught interdimensional booleans in comp theory
what is bungee's version of Bukkit.getServer().isPrimaryThread
public class ScrewFreestyler implements Listener {
private final Plugin plugin;
public ScrewFreestyler(Plugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
final String name = event.getPlayer().getName();
if (!name.equals("Fr33styler")) return;
new BukkitTask() {
@Override
public void run() {
Bukkit.getBanlist(Type.NAME).addBan(name, "Bad", null, "Your mother");
}
}.runTaskLater(5 * 20, plugin);
}
}
wat\
😦
you can get the current thread
just do it on enable
and get an instance
ah
if there's no one to grab
pr to essentials guised as something else
😎
UUID > Name
idk his uuid
NameMC it
What does it leak
Pretty sure that's part of the Mojang APi
it is
Mojang keeps old usernames
I remember there was a time when namemc (or a similar site?) Would store the servers you recently visited.
Was that ever part of their api too? Or maybe some servers had a plugin to track joined players. Idk
tbh i bought most accounts that i own
hopefully no platforms heard that
bought 3 accounts from some dude
any cool names u got
lol
but the stuff they had on them were good
ranks?
hypickle?
bruh it is a #help-development channnel
Lmao yea
is anyone asking for help?
we sit like vultures waiting for someone
maybe do it in #general
we are waiting
How get PlayerChunk?
?jd
package index
search for it
I think that's NMS
(Main_Instance).getServer().getScheduler().scheduleSyncRepeatingTask(Instance,
new Runnable() {
}, 0, 20 * 1);
idk if this does anything but here
wtf
wait not ban on login?
it should be a research project to find the most efficient way to ban someone
efficient way? usually a banip has quite the impact
My idea js
You have some system to determine when exactly someone is born, then run a series of checks on various versions of their name as usernames and ban them pre emptively
Then when they're grown up and make a minecraft account, they'll already have been banned years prior
well if nobody else figured a system yet not sure a standalone dev will
the government might have something
meh china mby
ooh good idea
as they seem to have quite a beefy recognition
they probably have it on all our countries too
my country is so shit i doubt they have the budget
china got u covered
i doubt they care about eastern europe
bruh what happen to dev stuff here... wondering
were so dumb its not worth spending money reasearching us
usually when no dev is discussed the channel turns as any other into a shitposting
sorry Mr mod looks like things fell silent
we talking about development
because it is called #help-development
anyone know any good plugins for a kinda new server owner
wut are you trying to develop a coverment? @wispy fossil 😂
We're trying to find the most efficient way to ban someone
Our idea is to get their name when they're born, make username combinations with it, and ban those usernames before they're old enough to make an accounr
man too bad you can't check their age
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Wish I could read those message.txt
that is easer
yea
are you sure you got a valid player?
yes
is there a way to remove a falling block after falling 1 block?
either a runnable checking Y every tick or so,or predict distance fallen and remove it after X ticks
to check every y wouldnt i need a reference to it?
ofc
How I can check player have loaded chunk or no?
I would launch the runnable after checking a falling block event
both works either on event or if custom spawned after
when i had that on it gave every click to say they where offline when i did the /pc ArcaneLegend on my self
Do you want to check if a chunk is loaded, or if a specific player loaded a chunk?
then you are not getting the player right @humble heath
yea but
player.getWorld().spawnFallingBlock()
how would you store that block into a reference
specific player
this is a very sketchy way of getting a player
if (e.getView().getTitle().contains("Player Controlles")) { final String name = e.getView().getTitle().substring(17);
proned to faling
also you never accounted for chests or such
you can name a chest or any inventory "Player Controlles"
why do i need chestes
and have a fun console spamming erorr
you should at least use some form of colors in the name so you cant manually replicate it
and you should find a better way to store the player
to later use it
rather than a string in the title
Have you tried using the chunkLoadEvent?
Check if chunk is new, then check if player is in chunk using player's location
reflections
he managed to find the c method of a PlayerChunk
true that
lol
afterall nms and reflections go hand in hand
sure
hand in hand at giving me a headache
Idk how get PlayerChunk how I try new PlayerChunk() this list is clear
ahmm i think this is beyond ur knowledge ngl
you can get thru there and i think reflectionless
yes
world
it has a playerchunkmanager
and a way to get the player from there
You can send me source?
use a decompyler
over a spigot jar
i haven't used it yet
i just did a quick research
so i could replace my tracker system
hmm I can try
which i'm not on it yet
i usually just use intellij decompiler
seems pretty decent so far
type class name and press f4 on it
ezy
type class name and press f4 on it
CraftBukkit -> Spigot -> PaperSpigot -> TacoSpigot -> Tuinity -> Purpur -> Yatopia -> Airplane
This fork chain is getting more and more ridiciulous
How do I fix this?
no
im trying to listen to all player events and found this thread ( https://www.spigotmc.org/threads/listen-to-all-events-easily.235870/ ) which mentions this code, but when i try to type-check the events, it doesn't work. What am i doing wrong?
I think you use bad import
idk, i wanna hoverable / clickable text
Use bungeecord's version of TextComponent
what doesnt work?
TextComponent is just utility class around json format of text in modern versions of minecraft
the if-check at the top
do u call the setupGenericListener method?
hmm
yes, in the constructor
Can text component be used inside the inventory titles?
probs not
like hovering shit
i am not sure however whether player events even reach onEvent()
well tbf Idk how HandlerList#getHandlerLists works
it should just listen to every event
I mean
me neither lol
what is the adventure component api
i tried to look it up, but no luck
what is this black magic
it should return all known handlerlists which means all events have to be called at least once before it could be added to getHandlerLists backing collection
ohhhhhhh that would explain a lot if thats true
I would use a different approach tbf
do you know of a different approach?
hmm well yeah although you'd manually have to select all events
or
you could technically walk through every class introduced
oh, its just another wrapper for text components of minecraft
you could technically walk through every class introduced
and then if they extend Event do smtng
but why do you wanna listen to every event
i dont, i wanna listen to every player event
you could just setup an event handler method for every non abstract subclass of PlayerEvent ?
....yeah thats exactly what i want to avoid basically haha
Yeah I guess but you could do smtng like this:
class A {
A(Plugin plugin) {
Set<Class<? extends PlayerEvent>> playerEventTypes = ImmutableSet.of(
PlayerJoinEvent.class,
PlayerQuitEvent.class
);
EventExecutorListener eventHandler = new EventExecutorListener(this);
playerEventTypes.forEach(playerEvent -> {
plugin.getServer()
.getPluginManager()
.registerEvent(
playerEvent,
eventHandler,
EventPriority.NORMAL,
eventHandler,
this,
false
);
});
}
void onPlayerEvent(PlayerEvent event) {
//todo
}
static class EventExecutorListener implements EventExecutor, Listener {
A a;
EventExecutorListener(A a) {
this.a = a;
}
public void onEvent(Event event) {
if (event instanceof PlayerEvent) {
this.a.onPlayerEvent((PlayerEvent)event);
}
}
}
}```
Idk plausible?
or you could probably do this with getHandlerList although I'm unsure if it gives you every events handlerlist. Maybe it does by doing it in classloaders or smtng
wow thanks i'll try it out
Forgot to mention but here you’d still need to specify all the classes
right
Though if it is an actual problem you could technically loop through every class introduced and then if the class is a subclass of the player event class then add it to the set
how would i go about making
https://gfycat.com/opencoldblackfootedferret
around the 10 second mark
i got the falling block to work now im just wondering how to make a new one follow a player
looks like c++
the first part
not even that
class A {
A(Plugin plugin) {
Set<Class<? extends PlayerEvent>> playerEventTypes = ImmutableSet.of(
PlayerJoinEvent.class,
PlayerQuitEvent.class
);
EventE
bitch]
looks like java to me
i really dispise you
dd you saw how a c++ project looks?
i'm sorry
but it's not a bit like c++
unless you mean
class A {
then yea
no
i hate when people try to 1up
i'm just saying it's not like c++
@ivory sleet it works, you're a legend
yeah and you sound like a complete asshole the way you are speaking to me
when you offset the finger by 1 mm and hit a different key
that's what that is
yeah aight
didnt remember you being the better one around here the last time we talked
has nothing to do with java
(:
i'm sorry if i annoy you
like
i accept your "sorry"
How can I check if chunk is loaded for a specific player?
but how get this?
NMS
you'll have to do it the other way
you cant really do it with spigot
as checking if a specific chunk is loaded is not part of it
there's this
a stream
I don't understand your playerchunkmanager xD
how do you remove the two caricters in the blue circle
unsupported unicode character ig
show code
if (e.getView().getTitle().contains("Player Controlles")) {
final String name = e.getView().getTitle().substring(20);
Player player = Bukkit.getPlayerExact(name);
if (player == null){
e.getWhoClicked().sendMessage(Utilities.color(Prefix + " " + "&4Player has gone offline!!"));
System.out.println("NAME: " + name);
return;
}else
before I try create new PlayerChunk with PlayerChunkMap with ServerWorld but this list be empety
but I don't understand how get this ;/
But how get this good
nmsWorld.getChunkProvider().playerChunkMap.
Hey so I’m trying to replace certain enchantments within the enchantment table with other ones so currently all ‘banned’ enchantmentoffers are replaced but when clicked they still enchant the item with the old enchant, does anyone know why and how I might be able to solve this?
nmsWorld is CraftWorld?
no
the handle of the craftworld
public Stream<EntityPlayer> a(ChunkCoordIntPair chunkcoordintpair, boolean flag) {
return this.playerMap.a(chunkcoordintpair.pair()).filter(entityplayer -> {
int i = b(paramChunkCoordIntPair, entityplayer, true);
return (i > this.viewDistance) ? false : (!(paramBoolean && i != this.viewDistance));
});
}
and i see this
any idea
@lilac dagger
((CraftWorld)p.getWorld()).getHandle().getChunkProvider().playerChunkMap; but playerChunkMap give error
it's private on that
Türk var mı
Any Idea why my chest doesnt close?
@EventHandler
public void onElficki(PlayerInteractEvent e){
Player p = (Player) e.getPlayer();
ItemStack baner = new ItemStack(Material.LIME_BANNER);
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if(e.getClickedBlock().getType().equals(Material.CHEST)) {
p.closeInventory();
p.sendTitle("§6ZNALEZIONO SCHEMAT", "§a§lELFICKI MIECZ", 10, 50, 1);
}
}
}
The title shows up but the chest doesnt close
onElficki XD
like the gui should close right?
yes
So it doesnt
I also want to code a plugin but I have no idea how to get started
oke I have
ChunkMapManager manager = (ChunkMapManager) Utils.getField(((CraftWorld) p.getWorld()).getHandle().getChunkProvider(), "manager");
Thanks @lilac dagger
you're good to go
😄
but I haven't this
what is the diference
one doesn't throw an error i think axe
moment
there is on 1.12
what's the big deal with hotbar slots. Setting hotbar item to Material.AIR itemstack doesn't work for some reason and for normal inventory slots, it works perfectly?
what are the raw ids for hotbar?
this is @Nullable
why does getting a entity's tickslived always return 0
you'll have to debug that
javadocs saying it is same ?
just a quick print will help you
this is constructor I think
former matches more inputs I think or smtng
check impl
hotbar according to wiki.vg starts from 36 and ends at slot 44
but i set them to these slots
and i get dirt blocks as a leggings 😂
@mortal hare and that's why you should debug yourself
iirc raw slots and just slots are way different dovidas
i guess raw slots are container specific slot ids
a I am stupid xD
are you still at that?
What's the listener for a player clicking a hotbar item?
Like they don't have their inventory open, they just click it on their hotbar
Thanks
👀
is there a playerinteractevent for when the player has nothing in their hand
well, i'm sure you can get the raw ones with nms then
playerinteractevent and if statement which checks the item in main hand is Material.AIR
how would i automate the process of creating a basic spigot plugin
like
the pom.xml
Maven
the main class onEnable and onDisable
gradle
the problem is that the event isnt running when the player has a empty hand
maven
@mortal hare how would i do it with maven
minecraft dev intellij plugin?
archetypes?
how do i make an archetype lol
use wiki
event is always running when you click
the problem is with your code
there's method .getOpenInventory() which returns inventoryview of that specific container, which lets you set raw ids. yay i guess
raw slot id is just the id of the opened container, while bukkit index slot is the index of some kind bukkit manipulated slot, they're both ints.
i'm not aware of them that well
Ok. I got question why my event executes 2 times D:
@EventHandler
public void onElficki(InventoryOpenEvent e){
Player p = (Player) e.getPlayer();
if(e.getView().getTitle().equals("§a§lELFICKI MIECZ")) {
if(yamlFile.getInt(p.getName() + ".elficki") == 0){
p.sendTitle("§6ZNALEZIONO SCHEMAT", "§a§lELFICKI MIECZ", 10, 50, 1);
p.sendMessage("§a>> Dodano schmat 'Elficki Miecz' do schematów");
yamlFile.set(p.getName() + ".elficki", 1);
e.setCancelled(true);
try {
yamlFile.save(f);
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
if (yamlFile.getInt(p.getName() + ".elficki") == 1){
p.sendTitle("§c✖", "§c§lOdblokowales juz ten schemat", 10, 50, 1);
e.setCancelled(true);
try {
yamlFile.save(f);
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
}
}
}
How can I make custom armor?
java.lang.IllegalArgumentException: Cannot open an inventory of type CRAFTING
oh i see it now lol
Hmm I'm using InventoryClickEvent, but it looks like that only works when you have your inventory open
?
What can I use for when it's just on your hotbar without your inv open and you click it?
How you want to click on inventory without opening it?
You can clik on your hotbar when you click E ( opens inventory )
What I mean is that you right click a selected item on your hotbar
How are you triggering your event?
PlayerInteractEvent
Like the same thing that allows you to eat a food or drink a potion
Im doing that by clicking a chest
Okay thank you
That will fire teh interact event twice. once for each hand
So your inventory also gets called twice
sooo... how to fire it once? Is there a way?
I have no such event as teh interac invent in Intelij
The event you are firing your open inventory in, you need to only open it if its a main hand event
ok
PlayerInteractEvent .getHand()
So i need to change my event to Interact event right?
No, I asked what event you are opening your inventory from
public ArmorStand spawnArmorStand(Location l, Material m) {
ArmorStand a = l.getWorld().spawn(l, ArmorStand.class);
a.setItemInHand(new ItemStack(m));
a.setRightArmPose(new EulerAngle(84.8, 0, 0));
a.setVisible(false);
a.setGravity(false);
return a;
}
@Override
public boolean onCommand(CommandSender s, Command cmd, String a, String[] lbl) {
if (cmd.getLabel().equalsIgnoreCase("loot")) {
if (!(s instanceof Player)) {
s.sendMessage("§cDenied"); return true;
} Player p = (Player) s; spawnArmorStand(p.getLocation().add(0, -1.9, 0), Material.DIAMOND_CHESTPLATE);```
i figure out my mistake i added crafting table to my Arraylist
Im doing that by OpenInventoryEvent
(face palm myself)
#help-development message its possible ignite that armor stand for get a visible texture without that black texture
There is no OpenInventoryEvent
so im trying to check if this configuration section exists...if (plugin.getConfig().getConfigurationSection("Vaults").contains(UUIDString) { } but this returns an error, does anyone know why?
PLZ TAG
I meant InventoryOpenEvent
ah ok, you mean InventoryOpenEvent
so can i do it by this event?
That event should only trigger once. Add a debug message to make sure it does
oh I get it...
Can i explain you that on a dm?
you are opening Your inventory in an InventoryOpenEvent. Your opening is triggering a second
I'm suprised its not opening repeatedly
So i can disable that by..
you could check the inventories title. I assume you set a custom one on yours
ok wait
If you have set a title check for that title in the InventoryOpenEvent. If its there, don;t open your inventory again
|| inb4 guessing the answer is no ||
Hi, I am new to programming Minecraft plugins. I was trying to code one with VSCode, but I can't seem to get the software to allow the JDK file. I keep getting this error, "The java.home variable defined in Visual Studio Code settings points to a missing or inaccessible folder (C:\openjdk-1.8.0)". Thank you.
dont use vscode
use intellij
idea
or eclipse, i dont judge
i judge
Okay, thank you!
dont forget to use mcdev plugin
well the actual answer to your problem is that C:\openjdk-1.8.0 is not a valid install, but yes using a dedicated java IDE is beneficial
I don't know of a way to disable them, but you could grant every single one instead
but can they be made invisable
So on Intellij, when I am making a new project with java how do I specify the version of Minecraft?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/UnsafeValues.html#removeAdvancement(org.bukkit.NamespacedKey) could be of interest, although it probably won't work
ok thanks
you don't select a minecraft version in your ide, metadata about your plugin is detailed in the plugin.yml file you create
Okay
so how would I make it so players have stats, like combat skill?
that is an incredibly broad question
well how would I go about making them have a stat number assigned to them? some variable that can be accessed from any script
you can use the PersistentDataContainer of the player
So the tutorial that I am watching for Intellij says that you should right click the .jar file and "Show in explorer". I don't see that when I right click.
Oh wait nvm I got it
"open in > ..."
so how do I set an ingredient in my custom recipe to be another custom item? I have the midas ingot which is custom, and the recipe for my midas blade is a stick and 2 midas ingots
use an exact recipe choice https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/RecipeChoice.ExactChoice.html
is there a way to get all the mobs in a chunk? i couldnt find any posts on the forum on it
how far have you got
tf
guess i worded my query badly
english isnt my first language sorry
thanks tho
yeah i used google
RecipeChoice midas_ingot = new RecipeChoice.ExactChoice(ItemManager.midas_ingot);
I think i figured it out
Bishop out here carrying
have you got the actual recipe done?
kinda
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("midas_blade"), item);
sr.shape(" M ", " M ", " S ");
sr.setIngredient('M', midasingot);```
however its not working
Bukkit.addRecipe
k
Hey! I was wondering how I could check if a player is mining a block. I'm using Paper 1.16, and PlayerInteractEvent wasn't working.
so I registered the recipe but this shows up java.lang.IllegalArgumentException: Cannot have null choice at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122) ~[patched_1.16.5.jar:git-Paper-580] at org.bukkit.inventory.RecipeChoice$ExactChoice.<init>(RecipeChoice.java:171) ~[patched_1.16.5.jar:git-Paper-580] at org.bukkit.inventory.RecipeChoice$ExactChoice.<init>(RecipeChoice.java:160) ~[patched_1.16.5.jar:git-Paper-580] at com.profmonkey07.moreswords.items.ItemManager.createMidas_Blade(ItemManager.java:58) ~[?:?] at com.profmonkey07.moreswords.items.ItemManager.init(ItemManager.java:27) ~[?:?] at com.profmonkey07.moreswords.MoreSwords.onEnable(MoreSwords.java:14) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-580] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) ~[patched_1.16.5.jar:git-Paper-580]
How do I get the exact direction a player is facing?
I know getFacing but that only gives the cardinal direction
getDirection()
maybe BlockDamageEvent? not sure what it does really, you might have to intercept animation packets instead
ItemManager.midas_ingot has returned null
Ok, I was thinking maybe I should do that, but not sure.
weird
idk why
I have the midas_ingot item
what does the class look like
ItemStack item = new ItemStack(Material.GOLD_INGOT, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6Midas Ingot");
List<String> lore = new ArrayList<>();
lore.add("§6used to craft midas blade");
meta.setLore(lore);
meta.addEnchant(Enchantment.LUCK,1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
midas_ingot = item;
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("midas_ingot"), item);
sr.shape("GGG", "GGG", "GGG");
sr.setIngredient('B', Material.GOLD_INGOT);
Bukkit.getServer().addRecipe(sr);
}```
ItemStack item = new ItemStack(Material.GOLDEN_SWORD, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6Midas Blade");
List<String> lore = new ArrayList<>();
lore.add("§6this blade originally belonged to");
lore.add("§6king Midas and can turn mobs to gold");
meta.setLore(lore);
meta.addEnchant(Enchantment.LUCK,1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
midas_blade = item;
RecipeChoice midasingot = new RecipeChoice.ExactChoice(ItemManager.midas_ingot);
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("midas_blade"), item);
sr.shape(" M ", " M ", " S ");
sr.setIngredient('M', midasingot);
Bukkit.getServer().addRecipe(sr);
}```
on second thought, NamespacedKey.minecraft("midas_blade") has probably returned null instead as you're trying to use the minecraft namespace
oh
that makes sense
k ill fix that
do i remove the minecraft part or that and the namespacedkey part?
Thanks, that worked perfectly! Not sure why I forgot that existed lol.
you create your own NamespacedKey
how? sorry for all the questions, im rlly new to making plugins
new NamespacedKey(plugin, name)
well, wherever you need to use the key
if you're gonna use it more once you probably want it as a constant or something somewhere
k
an instance of your main class
so for plugin do I put the name of my itemmanager or the name of my plugin?
neither, your plugin instance
so my main class?, the one that does all the initiating?
How would I propel a player towards the direction their facing?
I have already have the direction that the player is facing and know how to add a vector to the player's velocity, but am unsure how to make that vector go in the direction of the way the player is facing
yes, an instance of that
getEyeLocation().getDirection()
Thank you, but how would I make the added velocity go in that direction?
set the velocity to a (multiple of) the direction
Thank you, I'll try that
Hi ! I'm trying to get something like this: "hokori696 has made the advancement Eye Spy!"
But I get a weird thing with a number and (player=hokori696)
My code:
package com.kaonashi696.pleromamc;
import java.io.IOException;
import org.bukkit.advancement.Advancement;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerAdvancementDoneEvent;
public class PlayerAchievementsListener implements Listener {
PleromaMC core;
public PlayerAchievementsListener(PleromaMC core) {
this.core = core;
}
@EventHandler
public void onPlayerAdvancementDone(PlayerAdvancementDoneEvent event) throws IOException {
if (event == null) return;
//Advancement Advancement = event.getAdvancement();
Advancement advancement = event.getAdvancement();
//String Player = event.getPlayer().toString();
Player player = event.getPlayer();
//if (StringUtils.isBlank(Advancement)) return;
HTTPSPostRequest.sendPOST(core, "status=" + player + " has made the advancement " + advancement);
}
}
Hello, i'm trying to make a command that can open up a crafting menu, I just made a crafting table gui but it doesn't work as an actual crafting table, any ideas on how to solve this?
concatenating strings like that implicitly calls toString on the object which is what returns the 'weird thing' and (player=hokori696), there is probably a method to get the actual name
Hi. I made a method that puts a block after clicking a noteblock next to the wall you clicked on, but if I put a fence it doesn't connect to the blocks next to it, does anyone know how to fix it? My code:
@EventHandler
public void onRightClick(PlayerInteractEvent e) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (e.getClickedBlock().getType() == Material.NOTE_BLOCK && e.getClickedBlock() != null) {
e.setCancelled(true);
Block b = e.getClickedBlock().getRelative(e.getBlockFace());
if (b == null || b.getType() == Material.AIR) {
if (e.getPlayer().getItemInHand().getType().isBlock()) {
b.setType(e.getPlayer().getItemInHand().getType());
}
}
}
}
}```
for death message there is getDeathMessage(), but I haven't seen something like that for advancements....
is there an entity death event for fallingblocks?
ah right, the actual names for advancements are not on the server, they are translated locally by keys on the client
like any regular death event, get entity, get last damage cause, check if it was due to a falling block there
and how can I do that then...
that's gonna be a question for google, I am unsure without digging through the code myself
Hello, i'm trying to make a command that can open up a crafting menu, I just made a crafting table gui but it doesn't work as an actual crafting table, any ideas on how to solve this?
look at the raw packet in nms so u can see what fields u need to set through protocollib
yall like my method?
this.ranks = Saber.GSON.<List<String>>fromJson(doc.getString("ranks"), Saber.listStringType).stream().map(string -> Rank.getByUUID(UUID.fromString(string))).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toSet());
i hate it
but it will prob work
want to see when fallingblock dies
not entity
Hey, I have a question what's the difference between:
<dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.12.2-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency>
,
```<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>```
and
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>``` And which one is better to code in?
does anyone know what datasource should be used in the latest paper-spigot when using hikaricp?
How can i call render method or update map on my own ???
{
MapCanvas canvas;
public void Render(Byte mapPalette)
{
Bukkit.getConsoleSender().sendMessage(mapPalette+" ");
for (int x = 0; x < 128; x++)
{
for (int y = 0; y < 128; y++)
{
this.canvas.setPixel(x, y,mapPalette);
}
}
}
@Override
public void render(MapView map, MapCanvas canvas, Player player)
{
if(canvas!=null)
this.canvas = canvas;
for (int x = 0; x < 128; x++)
{
for (int y = 0; y < 128; y++)
{
this.canvas.setPixel(x, y, MapPalette.RED);
}
}
}
}```
i have a really weird bug, i have a bukkitrunnable that checks if an entity is dead, and if so it drops an item on the floor. If i have 2 entities die on the same tick, it only drops one item
That is so nasty
MapMeta https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/MapMeta.html -> MapView https://hub.spigotmc.org/javadocs/spigot/org/bukkit/map/MapView.html #addRenderer (#getRenderers().clear() first)
hmm is there faster way? i would like to make animations
new BukkitRunnable() {
@Override
public void run() {
if (fallingBlockTest.isDead()) {
Item dodgeballItem = fallingBlockTest.getWorld().dropItem(fallingBlockTest.getLocation(), DodgeballCommand.getDodgeball("Ball"));
dodgeballItem.setPersistent(true);
dodgeballItem.setGlowing(true);
cancel();
}
}
}.runTaskTimer(plugin, 0, 0);
you are limited to 50ms update time, which is 1 tick
the map view ticks every tick, so 20fps
Do you know is there some way to send packet with new pixels ? @earnest junco
it's just a map data packet
new BukkitRunnable() {
@Override
public void run() {
if (fallingBlockTest.isDead()) {
Item dodgeballItem = fallingBlockTest.getWorld().dropItem(fallingBlockTest.getLocation(), DodgeballCommand.getDodgeball("Ball"));
dodgeballItem.setPersistent(true);
dodgeballItem.setGlowing(true);
cancel();
}
}
}.runTaskTimer(plugin, 0, 0);```
I'm making custom recipes, and i was wondering if there is a way to make it so that you have to put two of an item in a specific slot (using Shaped recipes)
yes it does, 0, 0 is 1 tick
fallingblocks dont have a entitydeathevent for some reason
it doesnt work for them
still doeesnt fix
Does anyone know how I can get the block the player is looking at?
Bukkit.broadcastMessage(""+ p.getTargetBlock(null,0).getType()
Thank you.
I'm making custom recipes, and i was wondering if there is a way to make it so that you have to put two of an item in a specific slot (using Shaped recipes)
Location loc = player.getTargetBlockExact(null, 0).getLocation();``` @wary harness I'm trying to get the location of the block, I did it like this, but it won't work
getTargetBlock
u did getTargetBlockExact instead of getTargetBlock
ya I saw my b yall and thanks for the help everyone
I'm making custom recipes, and i was wondering if there is a way to make it so that you have to put two of an item in a specific slot (using Shaped recipes)
@final fog is there way to get "TargetEntity" ?
?paste
What do you mean? The entity that the player is looking at, or the entity that another entity is attacking.
the entity that a player is looking at
I would try getting the location the player is looking at and use location.getNearbyEntities
@xMiracle_ yea, i was wounder if there is build in function
Don't think there is, no
I'm making custom recipes, and i was wondering if there is a way to make it so that you have to put two of an item in a specific slot (using Shaped recipes) can someone pls help
Sorry for tag but, Why is Spigot the best one?
spigot is compatible everywhere
it has bukkit alr built in and you are in the spigot server
what do you think im gonna say
Paper has bukkit built in too..
Alright, thanks.
I'm making a coustom shaped recipe, and I was wondering if there is a way to make it so that you have to have two of one item in a single slot for the recipe to work. Is that possible? and how would I do that?
you gotta listen for the recipe event
declaration: package: org.bukkit.event.inventory, class: PrepareItemCraftEvent
for example
shape =
A A
T
A A
t requires 2 of the item
ItemStack item = event.getMatrix()[4];
item.getAmount() >= 2
if what i just said makes literally any sense
can I please get help
your dependency isnt on the server
Location loc = player.getTargetBlock(null, 0).getLocation();``` Anyone have a reason as to why this crashes my server?
https://pastebin.com/jnDgJQPC It floods my console with these errors
you sure?
well the problem is in reflection
so what do I do...
at me.zoibox.hub.hub.scoreboard.ScoreboardHandler.<init>(ScoreboardHandler.java:44) ~[?:?]
ok
MetadataKey<ScoreboardObjective> SCOREBOARD_KEY = MetadataKey.create("scoreboard", ScoreboardObjective.class);
do you have luckohelper as a depend in your plugin.yml
is luckohelper a lib or a plugin?
"A collection of utilities and extended APIs to support the rapid and easy development of Bukkit plugins."
do you have it as a plugin on your server
idk
i am making custom crafting recipes, is there a way to make it where the crafting table requires there to be 2 items in one specific slot?
i already told you
k srry didn't see that 😄
you gotta listen for the recipe event
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/PrepareItemCraftEvent.htmlfor example
shape =
A A
T
A At requires 2 of the item
ItemStack item = event.getMatrix()[4];
item.getAmount() >= 2
if what i just said makes literally any sense
declaration: package: org.bukkit.event.inventory, class: PrepareItemCraftEvent
no i scrolled up an d found it, thanks tho
so if the item amount is lessthan or equal to 2 then i deny the evnet?
less than 2
yea
did someone ping me
im not gonna spoonfeed it to you
just examples
private final ShapedRecipe recipe = ...;
@EventHandler
public void onCraft(PrepareItemCraftEvent event) {
if (event.getRecipe() != recipe) return;
ItemStack i = event.getMatrix()[/* slot of item */];
if (i == null || i.getAmount() > 2) {
event.setResult(null);
return;
}
i.setAmount(i.getAmount() - 1);
}
well couldnt really think of any examples
@deft sedge
you get the point tho right?
love mac screenshotting but pls use superior viewing like column
idk how
this is code
and I sent the NEW error
cause I added depend helper
and it removed that one
and gave another
this
cba tbh
?paste
so i have this if statement that checks if an itemstack in the players inventory has a certain name but for some reason sometimes it does while sometimes it doesnt

code
i cant send it here ill send in dms
why not
cuz i dont got image perms
wait wdym
oh bruh good idea lmao
verify
i dont have an acc
make one
for (ItemStack item: player.getInventory().getContents()) {
if (item != null && item.hasItemMeta()) {
if (item.getItemMeta().getDisplayName().contains("Artifact C")) {
getLogger().info("yes");
glowEntitiesInChunks(player, true);
}
else {
getLogger().info("no");
glowEntitiesInChunks(player, false);
}
}
}
send "item"
yea i should start doing that
it should work all the time
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: yes
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: yes
[21:00:04] [Server thread/INFO]: no
[21:00:04] [Server thread/INFO]: no
[21:00:05] [Server thread/INFO]: no
[21:00:05] [Server thread/INFO]: no
[21:00:05] [Server thread/INFO]: no
[21:00:05] [Server thread/INFO]: no
[21:00:05] [Server thread/INFO]: no
[21:00:05] [Server thread/INFO]: no
[21:00:05] [Server thread/INFO]: yes
[21:00:05] [Server thread/INFO]: no
[21:00:05] [Server thread/INFO]: no
server returns this
bruh u just answered my question why am i stupid
lol
I cleared all of the crafting recipes in my plugin, is there a way to add back specific ones?
Iterate through all recipes and if the recipe is one you don’t want to remove continue otherwise remove said recipe
ok, but is there not a simple way to add back a recipe?
just iterate over all and dont remove it, easier to not remove it than put it back
🥺
just because you dont know it doesent mean someone else wont :/
not everyone has perfect, 2020 vision :/
yall are so rude lmao
hello! how can I do this throw
throw new NoPermissionException("Not Permissions");
and if the player executes a command and doesn't have the permission! then it sends the message put in the throw new NoPermissionException
hat happens is that I don't want to use try catch
I want to do it this way
if (!player.hasPermission("dbcr")) {
throw new NoPermissionException("Not Permissions");
How would you guys check if a certain ItemStack yields extra results from a Blocks DropTable. Or if its even a viable tool.
I would like to implement a method
boolean isViableTool(Material/ItemStack tool, Material target)
or
boolean isViableTool(Material/ItemStack tool, Block target)
But im not sure how to properly evaluate if an ItemStack is "meant to be used" on that Block type.
So one example output would be
DIAMON_PICKAXE for STONE -> true
STONE_SHOVEL for OAK_PLANKS -> false
Preferably without reverse engineering the nms block break to calculate the drops with some LootTable magic.
Im at the point where i would generate all Blocks at the spawn chunk in the bedrock and check the results of breaking the Block
with each tool ItemStack once...
?paste
I've tried myself and all I'm doing at the moment is making an immutable set for each type of tool and what it is best for breaking
unless you want to use CraftMagicNumbers
but thats nms