#help-development

1 messages · Page 1373 of 1

untold onyx
#

viaversion is a PLUGIN on SPIGOTMC

stone sinew
#

I might be misreading then lol. What version is your server?

untold onyx
#

1.7

stone sinew
#

You can't have glow then

untold onyx
#

yes u can

graceful crypt
#

yes u can

untold onyx
#

how did hypixel do it

stone sinew
#

Hypixel is 1.8.8

untold onyx
#

yes hwatst he differnce

stone sinew
young knoll
#

I assume they also use some packet tricks

crude charm
young knoll
#

If you intend to run old versions, you are expected to support them yourself

stone sinew
#

spectator mode was added in 1.8 which was when the glowing effect was added right?

young knoll
#

1.9

solemn shoal
#

hm

stone sinew
solemn shoal
crude charm
#

why run 1.7 in the first place, I understand older versions for pvp but why not run 1.8 its the same thing in every way and is 100x better for development

young knoll
#

Yes spectator is 1.8

#

But glowing is 1.9

solemn shoal
#

wait nvm

untold onyx
young knoll
#

Okay

stone sinew
young knoll
solemn shoal
#

also, recommended way to hide ores?

untold onyx
#

1.7 oLD STfU LITTlE KId literally the whole pvp community uses it

young knoll
#

Spectators are translucent

young knoll
solemn shoal
#

1.7 is ancient

#

please update to at least 1.16.5

crude charm
#

you have no clue what you are talking about

untold onyx
young knoll
#

A lot of big servers run 1.8, but that does not mean it's anywhere near the most used version
Also those big servers can fix issues themselves

solemn shoal
#

go get 1.16.5 and NoAttackCooldown

untold onyx
crude charm
untold onyx
#
  1. its retarded and its a cpu shitter
solemn shoal
#

i use 1.16 for pvp

young knoll
crude charm
solemn shoal
#

also "weird animations"?

untold onyx
solemn shoal
#

how do you mean gm?

#

uh

#

youre using a fork of bukkit

crude charm
#

no what gamemode

#

what pvp gamemode

untold onyx
#

im using spigot

crude charm
#

like practice and stuff

untold onyx
#

o

solemn shoal
#

idk i just have a survival server

crude charm
#

yeah makes sens

solemn shoal
#

doeskt bukkit itself have like, bstats built in?

#

spigot does for sure

crude charm
#

im talking kitpvp, ffa, soup, practice, uhc ect

untold onyx
#

any smartasses who can help fix this on 1.8 and people who dont skid code

young knoll
#

Doubt it

young knoll
#

I assume the process is the same as modifying the newer source

solemn shoal
#

add a plugin for backwards support

stone sinew
#

So you want to be able to add glowing in 1.7 and 1.8?

solemn shoal
#

ProtocolSupport is pretty good

crude charm
#

@untold onyx I rarely tell people to use 1.16 unless its survival and stuff but its the only way to do it, from there you can just apply the effect and the game will do the rest

#

otherwise if ur doing practice or smth just use 1.8 and dont hhave it

solemn shoal
#

1.8 is a whole 8% of the servers

#

1.7 is 0.9%

young knoll
#

People seem to think because most big servers run it that everyone runs it

crude charm
#

I wouldn't go based off usage

young knoll
#

Which just isn't how it works

crude charm
#

ik

#

im just saying

solemn shoal
#

apparently people still run bukkit

crude charm
#

from my years if experience with practice and pvp servers all of them run 1.8

#

1.16 is perfect for survival and stuff

young knoll
#

There isn't anything wrong with running it, you just need to be aware it contains issues and exploits fixed in newer versions

dusty herald
crude charm
#

but for pvp servers

young knoll
#

And that you are very likely to not receive support from the spigot/paper/whatever devs

crude charm
#

alot of people have custom forks

solemn shoal
#

no i mean like, pure bukkit @dusty herald

dusty herald
#

🤷

young knoll
#

Some people are strange I guess

dusty herald
#

maybe they're doing testing

shut mango
#

can any1 help me out? i have this error "could not pass event InventoryClickEvent" i cant use some guis. any fixes?

shut mango
#

Yes

#

one sec

drowsy helm
#

and your error code should be much longer

#

if we can see that aswell

#

?paste

queen dragonBOT
candid galleon
#
    //Clear Chat
    if(Conditions.cheatEntered("clearChat")){
      Actions.displayChatMessageToAll(" ");
      Actions.displayChatMessageToAll(" ");
      Actions.displayChatMessageToAll(" ");
      Actions.displayChatMessageToAll(" ");
      Actions.displayChatMessageToAll(" ");
#

some nice old cold I found

#

that goes on for like 200 lines btw

shut mango
#

@drowsy helm i saved it in that link how do i show u

drowsy helm
#

paste the link in this chat

shut mango
young knoll
#

Loops aren’t real anyway

drowsy helm
#

the code aswell

#

BalloonManager

#

@shut mango is this your own plugin?

shut mango
#

No i installed it

drowsy helm
#

oh why post in this channel then lol

#

this is for fcoding

#

you'll have to message the plugin developer

shut mango
#

Like i said i am new and kinda dumb

#

i apologize

drowsy helm
#

you're fine lol

dusk wedge
#

how do I get the inventory name when using InventoryClickEvent?

young knoll
#

event.getView.getTitle

drowsy helm
#

getView

#

but you should use it if you're making a gui system

young knoll
#

You should use the inventory view returned by openInventory

quaint mantle
#

What's the best way to update a boss bar relatively quickly? As in every few ticks.

#

What I want is a boss bar that counts down when certain players are within a certain area, and gets removed when it gets to zero (and runs some code). Is this just done with a scheduler and state variables?

#

Bukkit.getOnlinePlayers().forEach(p -> p.getWorld().dropItem(p.getLocation(), new ItemStack(Material.ACACIA_BOAT, 1))); Doesn't work 😦

java.lang.IllegalStateException: Asynchronous entity add!
        at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:15) ~[patched_1.15.2.jar:git-Paper-391]
        at net.minecraft.server.v1_15_R1.WorldServer.addEntity0(WorldServer.java:1238) ~[patched_1.15.2.jar:git-Paper-391]
        at net.minecraft.server.v1_15_R1.WorldServer.addEntity(WorldServer.java:1175) ~[patched_1.15.2.jar:git-Paper-391]
        at org.bukkit.craftbukkit.v1_15_R1.CraftWorld.dropItem(CraftWorld.java:735) ~[patched_1.15.2.jar:git-Paper-391]
        at me.toto.main.utils.SpawnResources$1.lambda$run$0(SpawnResources.java:27) ~[?:?]
        at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
        at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085) ~[?:?]
        at me.toto.main.utils.SpawnResources$1.run(SpawnResources.java:27) ~[?:?]
        at org.bukkit.craftbukkit.v1_15_R1.scheduler.CraftTask.run(CraftTask.java:99) ~[patched_1.15.2.jar:git-Paper-391]
        at org.bukkit.craftbukkit.v1_15_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:54) ~[patched_1.15.2.jar:git-Paper-391]
        at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.15.2.jar:git-Paper-391]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:834) [?:?]```
#

idk reallly what is problem

eternal oxide
#

You are trying to drop items from an Async thread.

quaint mantle
#

oh

#

ye

eternal oxide
#

You can;t make changes to the world Async

quaint mantle
#

ah

#

ty

#

yes :)) it works

torn oyster
#

how would i check if a livingentity was spawned by a mob spawner

summer scroll
young knoll
#

You can add some data to them in the spawn event

#

Like pdc or metadata

quaint mantle
#

Would anyone know why I can't import my Events class to register them into my main method? It was working fine 3 days ago when I was building everything however after I exported it and went back into the files it showed that I couldn't import them.

@ me in response please.

teal flower
teal flower
#

Also try
Bukkit.getPluginMamager().registerEvents(new ClassFile(this), this);

dusty herald
#

Mamager

#

don't use new ClassFile(this) unless you have dependency injection, which I highly suggest you implement

teal flower
#

I write it on phone

dusty herald
#

👀

teal flower
quaint mantle
#

Anime pfp, also was doing

getServer().getPluginManager().registerEvents(new ClassFile , this);

teal flower
#

You have banned in Google?

#

"How register events Bukkit?"

dusty herald
teal flower
#

May be without New

quaint mantle
#

hello, sorry if this question is asked alot but where can i download the Spigot .jar/API for coding my own plugins?

queen dragonBOT
dusty herald
#

?bt

#

You have to compile it yourself, since the DMCA it is no longer legal to redistribute spigot jars

young knoll
#

What

quaint mantle
#

ah makes sense. Thank you @dusty herald

dusty herald
#

Althought, with Maven you can use the spigot's repository

solemn shoal
#

protip for gradle:

#

put your source dir as resources too

young knoll
#

You can use the API with maven or gradle, but for NMS you need to run buildtools

solemn shoal
#

^

young knoll
#

And for the jar itself, of course

dusty herald
#

this is the gradle I use for my project

import org.apache.tools.ant.filters.ReplaceTokens

plugins {
    id 'java'
}

group = 'io.github.jochyoua'
version = '1.0'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

repositories {
    mavenCentral()
    maven {
        name = 'spigotmc-repo'
        url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
    }
    maven {
        name = 'sonatype'
        url = 'https://oss.sonatype.org/content/groups/public/'
    }
}

dependencies {
    compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
}

processResources {
    from(sourceSets.main.resources.srcDirs) {
        filter ReplaceTokens, tokens: [version: version]
    }
}```
#

dont judge

solemn shoal
#

thats pretty small

young knoll
#

I really need to add the version replacement to mine

#

But I’m too lazy to be lazy

solemn shoal
#

i dont have that either

dusty herald
#

dont need anything else

young knoll
#

The maven

dusty herald
#

yes it does the maven

young knoll
#

Sounds like a bad 80s dance move

solemn shoal
#
plugins {
    id 'com.github.johnrengelman.shadow' version '6.1.0'
    id 'java'
}
apply plugin: 'java'

repositories {
    jcenter()
    mavenCentral()
    mavenLocal()
    maven {
        url "https://jitpack.io"
    }
    maven {
        url "https://repo.codemc.io/repository/maven-public/"
    }
    maven {
        url "https://papermc.io/repo/repository/maven-public/"
    }
    maven {
        url "https://www.basinmc.org/nexus/repository/maven-releases/"
    }
}
group = "net.thearcanebrony.essentialtools"
version = project.property("version")
sourceCompatibility = 1.14
sourceSets {
    main {
        java {
            srcDirs = ["src/"]
        }
        resources {
            srcDirs = ["src/"]
        }
    }
}
dependencies {
    //compileOnly "org.yatopiamc:yatopia-api:1.16.5-R0.1-SNAPSHOT"
    compileOnly "org.spigotmc:spigot:1.16.5-R0.1-SNAPSHOT"
    compileOnly "com.github.MilkBowl:VaultAPI:1.7"
}
task copyToTestServer(type: Copy){
    from 'build/libs/essentialtools-master.jar'
    into 'D:/spigot test/plugins/'
}
task makeBukkitJar (type: Jar){
    from 'build/classes/java/main/'
    if(file('/.arcane').exists()){
        logger.info("Copying to test server!")
        dependsOn copyToTestServer
    }
}
jar {
    shouldRunAfter(build)
    archivesBaseName = "EssentialTools"
    dependsOn makeBukkitJar
}```
#

this is mine

dusty herald
solemn shoal
#

@dusty herald

dusty herald
#

is that

#

PAPER API

solemn shoal
#

not like im including it as a dependency

dusty herald
#

im being sarcastic

solemn shoal
#

just a leftover from when i was building against Yatopia lol

dusty herald
#

so it copies the plugin to a test server and runs it? 🤔

solemn shoal
#

not sure if that works

#

dont think so

dusty herald
#

weird i usually just build to a file and run it manually

#

like set the target dest to a server

young knoll
#

Having it copy to my server would be nice

dusty herald
#

I use maven but I could send you the config

young knoll
#

But then I’d have to modify the build file when I upload it to git

dusty herald
#

.gitignore

#

just manually update the file /s

solemn shoal
#

well thats why im using a conditional task

dusty herald
#
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <outputFile>./server/plugins/${project.artifactId}.jar</outputFile>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
</plugin>```
young knoll
#

But then it will have no build file on git

#

Why can’t gradle extract the server location from my brain

dusty herald
#

my POM is a mess

young knoll
#

Got enough dependencies?

dusty herald
#

no

solemn shoal
#

lol

#

ok so, i cant remove the papermc repo lol

#

otherwise vault throws an error

eternal oxide
#

thats nothign to do with paper

solemn shoal
#

if i remove the paper repo it throws that

eternal oxide
#

then you are not including the spigot repo

solemn shoal
#

which one is that?

eternal oxide
#

<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>

rotund ravine
#

You don’t need to depend on bukkit

solemn shoal
#

yeah fixed from jochyoua's pom

#

not my dependency

#

its a vault dependency

rotund ravine
#

Yaah. Well paper repo should have it anyway

solemn shoal
#

it does

#

anyways i replaced the paper repo with spigot

#

can anyone help me fix an xp duplication bug in my code?

rotund ravine
#

?paste

queen dragonBOT
solemn shoal
#

gimme oen sec

#

i was gonna link on gitlab

#

current behavior: barely does mending items, somehow i still gain xp?

eternal oxide
#

you are only picking up orbs in a single block

#

also its going to give you xp every time it finds an item that doesn;t need mending

#

Line 61 of your getLowest method is never going to be lower than the starting zero.

#

it shoudl be dl > du

#

currently its not doing mending at all. Not in your code.

solemn shoal
#

huh

#

oh right, because damageable

#

oh yeah its working properly now

#

thanks

#

tho it seems to duplicate the xp?

eternal oxide
#

increase teh range. you are probably picking up orbs in between your task running

#

or set the orb exp to zero before you remove, as the remove may not be instant.

stray halo
#

Hello, i'm trying to put a custom model data to a gun in crackshot, but there is no field for that in the configs.. Do i need to use its api?

solemn shoal
#

i tried setting it to run every tick @eternal oxide

#

still duplicates

eternal oxide
#

set teh exp on teh orb to zero

#

after you read it

solemn shoal
#

lets try that

dusty herald
solemn shoal
#

not what i said

#

i said Vault depends on it

solemn shoal
eternal oxide
#

increase your pickup range

quaint mantle
#

how to add a block with a Location var

solemn shoal
#

i set the range to 1 block, didnt work

sullen marlin
#

Location.setBlock ?

eternal oxide
#

I can;t see it duplicating

quaint mantle
#

I mean

#

like this
Location blockBreakd = e.getBlock().getLocation();

#

how can I place a block with this

eternal oxide
#

you are setting the exp to zero, you are removing the orb and you only assign exp when there is nothing left to mend.

solemn shoal
#

no i mean

#

its adding 2 durability

eternal oxide
#

oh

sullen marlin
#

blockBreakd.getBlock().setType(..)

eternal oxide
#
getRepairAmount
public int getRepairAmount()
Get the amount the item is to be repaired. The default value is twice the value of the consumed experience orb or the remaining damage left on the item, whichever is smaller.

Returns:
    how much damage will be repaired by the experience orb```
#

it seems it repairs 2 durability per exp

solemn shoal
#

ah

#

however im repairing it in code, so it shouldnt be doing 2

eternal oxide
#

your code isn;t

#

you repair once, then you look for the most damage item again

#

if yoru item is still teh most damaged it repairs again

solemn shoal
#

no?

eternal oxide
#

depends how many orbs you pick up I guess

quaint mantle
#

how to plant a carrot

solemn shoal
#

im testing with an xp orb with value 1

quaint mantle
#

i tried using block.setType

#

but it's not working

#

i'm not getting any errors

eternal oxide
#

add some debug and sysout when it performs a repair.

sullen marlin
#

if youre setting it in the break event you probably want to cancel the event so it isnt just broken immediately

quaint mantle
#
@EventHandler()
    public void onBlockBreak(BlockBreakEvent e)
    {
        if (e.getBlock().getType().equals(Material.CARROTS))
        {
            Location blockBreakd = e.getBlock().getLocation();
            System.out.println("trig");
            int carrotsAmount = ThreadLocalRandom.current().nextInt(1, 5 + 1);

            e.setDropItems(false);
            
            ItemStack carrot = new ItemStack(Material.CARROT, carrotsAmount);
            Player auth = e.getPlayer();
            auth.getInventory().addItem(carrot);
            
            blockBreakd.getBlock().setType(Material.CARROTS);
            return;
        }

i tried that

quaint mantle
#

but i want it to break

#

then replace it

#

but if i cancel the event, the carrot is not going to be break

#

like i want to "replant" carrot

sullen marlin
#

replace it after the event with a scheduler then

quaint mantle
#

why should I use a scheduler

#

i can't do it in the event ?

solemn shoal
#

no, schedule it one tick later

sullen marlin
#

well I dont get it because 'break then replace instantly' is the same as 'not break at all'

quaint mantle
#

no

sullen marlin
#

in which case just cancel the event and drop the items yourself

quaint mantle
#

if i cancel the event, the carrot will be at max growth

#

like

#

if i replant it, the carrot will not be at max growth

sullen marlin
#

well cancel the event and set it to 0 growth

solemn shoal
#

isnt there an api to set growth?

quaint mantle
#

how can I set growth

sullen marlin
#

just add e.setCancelled(true) before your return

#

setType will reset it to 0

quaint mantle
#

isn't what i did on my code?

#

because when I'm breaking a carrot, it doesn't replant it or anything

eternal oxide
#

if you don;t cancel the event the block will break

quaint mantle
#

i'm gonna try

#

tty

eternal oxide
#

It doesn;t matter what you set teh block to at teh end if you don't cancel. It will be overwritten

solemn shoal
#

well, now its always giving me xp

quaint mantle
#

okay ty it's working

#

how can I get the growth of a carrot

#

like know if it's at 100% or 10%

solemn shoal
#

isnt there like a subclass of Block?

eternal oxide
#

no

#

why?

solemn shoal
#

idk, for crops?

eternal oxide
#

oh, cast BlockData to Ageable

eternal oxide
#

no idea what crackshot is

stray halo
#

i'm not sure, it's still development

solemn shoal
#

now it doesnt work at all

stray halo
solemn shoal
#

same

#

ive heard of it

#

if im not mistaken its a gun thing

stray halo
#

yep

#

probably it's better if i ask it in its discord

solemn shoal
sullen marlin
#

I herd biden was gonna take away guns

solemn shoal
stray halo
eternal oxide
#

So you don;t get teh repaired message? add more debug

#

either you are getting an item that has no damage or null

#

duh, you changed your du variable to 99999

#

that shoudl be zero

stray halo
#

They don't have a discord server bruh

solemn shoal
#

oh right coz we inverted the check

#

not everything has a discord server

#

thankfully

#

itd be useful, sure, but a pain for people like me who are at the server limit

stray halo
#

but famous plugins should

eternal oxide
#

I'm UK, we fight with potato peelers and spoons.

#

Only the criminals have guns

solemn shoal
#

tfw it still doesnt work

stray halo
solemn shoal
#

variable is 0 now, still wont work

eternal oxide
#

show code again

eternal oxide
#

I see nothign wrong there

#

try printing the item (is)

summer scroll
#

Is teleporting player to an unloaded chunks can cause issues? Or the chunk will be loaded on teleport?

eternal oxide
#

causes errors

summer scroll
#

Okay, so I need to check If the chunk is loaded first?

#

Before teleporting.

eternal oxide
#

earlier tonight 7smile7 posted some code to load the chunk and then teleport the player. Search his name

#

His code was quite cleaver where it used a runnable to handle the teleport after teh chunk was loaded

summer scroll
#

Is it the teleporting players back to the lobby?

eternal oxide
summer scroll
#

Ah okay, but unfortunately the method isn't exist in 1.12.2. addPluginChunkTicket and removePluginChunkTicket.

quaint mantle
#

is there a way i can extend JavaPlugin when i already have implements CommandExecutor in my public final class?

eternal oxide
#

your main class shoudl always extend JavaPlugin

#

if not its not a plugin

quaint mantle
#

im trying to make an essential commands plugin

#

and im trying to take an int from my config.yml file

#

but the getConfig(). doesnt work without JavaPlugin

eternal oxide
quaint mantle
#

im following a 1.12.2 guide

#

for a 1.12.2 server

stray halo
#

make an instance of your main class

#

and get config from there

quaint mantle
#

ooh

#

imma try that

eternal oxide
#

do NOT do new Main

stray halo
#

yeah not that

summer scroll
#

Elgar, so what's my best option here? for 1.12.2 plugin.

stray halo
#

make a constructor(i think it's called in this way)

solemn shoal
#

new Main *visibly cringes*

eternal oxide
#

Sorry I only advise on current release

#

at a minimum 1.14

summer scroll
#

Ah alright, thanks anyways.

sullen marlin
eternal oxide
#

It will? I've generally seen teh teleport never happens or I thought it threw an error

sullen marlin
#

/tppos etc obviously work

summer scroll
#

Alright then, thanks for that.

quaint mantle
#

what do i do

summer scroll
eternal oxide
#

md_5 do you bother with takedowns of spigot on github? I got a notification yesterday when someone uploaded the full spigot

stray halo
#

sth like that

quaint mantle
#

I doubt md_5 would do that, mans doesn't have the time

stray halo
dusty herald
stray halo
#

same thing

dusty herald
#

no

stray halo
#

why not

dusty herald
#

easier read for my small brain

stray halo
#

but it's same thing bruh

dusty herald
#

it really isnt

#

see the plugin is plugin

stray halo
#

then explain why

dusty herald
#

not pl

#

tsk tsk tsk

stray halo
eternal oxide
#

His is better formatting and java norms... and prettier 🙂

dusty herald
#

or better yet
why not

public NotSoMainClass(MainClass plugin){
    plugin.getServer().getPluginManager().registerEvents.registerEvents(()->{
           @EventHandler
           public void onJoinEvent(PlayerJoinEvent event){
                event.getPlayer().setBanned(true);
                event.getPlayer().kick("You have been ban");
           }
    }, plugin);
}
#

dont do that

#

there is enough chaotic evil in this world as it is

dusty herald
#

Multiverse-Core

#

is this bad idea Elgar

#
static {
        try {
            File file = new File(MCSF.getInstance().getDataFolder(), "/logs/debug.log");
            File dir = new File(MCSF.getInstance().getDataFolder(), "logs");
            if (!dir.exists()) {
                dir.mkdirs();
            }
            if (!file.exists()) {
                try {
                    file.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            fileHandler = new FileHandler(MCSF.getInstance().getDataFolder()
                    + File.separator + "logs" + File.separator + "debug.log");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }```
#

🤔

sullen marlin
#

why you have file and dir

#

just call getFolder or whatever on the file

#

getParentFile or something

eternal oxide
#

if you call mkdirs on yoru first file it will make both directories

#

oh file and folder, ok

#

however, just call mkdirs on the first File, no need for the second

#

so your first file will be used for your mkdirs and your file handle

quaint mantle
#

Hey, i'm trying to make a NPC.
And when i'm creating and NPC, it says "NPC CREATED :D", but there isn't any NPC Created, and i'm not getting any errors.
Here is my code:

#
public class NPC {
    private static List<EntityPlayer> NPC = new ArrayList<EntityPlayer>();
    
    public static void createNPC(Player player)
    {
        MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
        WorldServer world = ((CraftWorld) Bukkit.getWorld(player.getWorld().getName())).getHandle();
        GameProfile gameProfile = new GameProfile(UUID.randomUUID(), ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "Shop");
        EntityPlayer npc = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager(world));
        npc.setLocation(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(),
                player.getLocation().getYaw(), player.getLocation().getPitch());
    
        addNPCPacket(npc);
        NPC.add(npc);
    }
    
    public static void addNPCPacket(EntityPlayer npc)
    {
        for (Player player: Bukkit.getOnlinePlayers())
        {
            PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
            connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER));
            connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
            connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) (npc.yaw * 256 / 360)));
        }
    }
    
    public static void addJoinPacket(Player player)
    {
        for (EntityPlayer npc: NPC)
        {
            PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
            connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER));
            connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
            connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) (npc.yaw * 256 / 360)));
        }
    }
    
    public static List<EntityPlayer> getNPCs()
    {
        return NPC;
        
    }
}
#

And here is my main:

Player auth = (Player) sender;
        
if (label.equalsIgnoreCase("createnpc"))
{
  NPC.createNPC(auth);
  auth.sendMessage("NPC Created :D");
}
#

can someone tells me why my NPC isn't "spawning"

round finch
#

i wanna make a world generator
where should i look for the resources needed to develop a world generator?

rugged topaz
#
for (Player p : Bukkit.getOnlinePlayers()) {
    Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, () -> {
        if (p.getLocation().getY() == 70 && Math.abs(new Location(Bukkit.getWorld("world"), -2.5f, 70.0f, -62.5f).distance(p.getLocation())) < 4) {
            teleportToSpawn(p);
        }
    }, 0, 1);
}

is this expensive? and is there a way to fix that

eternal oxide
#

wow yes it is, you are running a sync runnable per player and checking location every tick

rugged topaz
#

terrible that a lot of my code looks similar

#

i guess we can start by moving the instantiation of the location to a constant field

#

but apart from just that, seems impossible to really fix

eternal oxide
#

all you have to do is do a simple check if a player moves block in the PlayerMoveEvent.

rugged topaz
#

playermoveevent didn't seem fast enough

#

i made some changes since then and ig i'll see rn

eternal oxide
#

it fires every move

round finch
#

ooF
if you dont move

eternal oxide
#

if you don;t move it doesn;t matter

rugged topaz
eternal oxide
#
    @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
    public void onPlayerMove(PlayerMoveEvent event) {

        /*
         * Abort if we havn't really moved
         */
        if (event.getFrom().getWorld() == event.getTo().getWorld()
                && event.getFrom().getBlockX() == event.getTo().getBlockX()
                && event.getFrom().getBlockZ() == event.getTo().getBlockZ()
                && event.getFrom().getBlockY() == event.getTo().getBlockY())
            return;```
#

if they have not moved a full block this returns and aborts out

sonic basin
#
public void onPlayerWalk(PlayerMoveEvent event)  {
      Player plr = event.getPlayer();
      int x = plr.getLocation().getBlockX();
      int y = plr.getLocation().getBlockY() - 1;
      int z = plr.getLocation().getBlockZ();

      Material block = plr.getWorld().getBlockAt(x,y,z).getType();
      if (block == Material.STONE){
          plr.sendMessage(ChatColor.RED + "works");
      }
    }

sorry for the stupid question i am new to this but the playermove event wont fire when i step on stone block why doesnt it work

rugged topaz
#

sick ty

#

as for location#distance, i heard distanceSquared is faster than distance?

#

is that true

eternal oxide
#

it should be

#

as it doesn;t use sqr

ornate heart
wind dune
#

Why do I get this error?

eternal oxide
#

you shouldn't -1 on Y as the plate will be in teh same block as your feet

sonic basin
#

oh did they fix that?

#

i thought it would be in the middle

#

so i substracted 1

eternal oxide
#

just get teh block at teh players location, so event.getPlayer().getLocation().getBlock()

sonic basin
#

k got it

#

let me try

eternal oxide
wind dune
#

Nothing

#

I just run BuildTools

sonic basin
#

is it better to use /reload or just restart the server btw

eternal oxide
#

reload if testing. live restart

#

reload can break poorly written plugins

sonic basin
#

ok

sullen marlin
#

delete everything and also your .gitconfig in your user dir

wind dune
eternal oxide
#

If it breaks on reload I'd have to say yes.

#

I doubt it does though

sullen marlin
#

if it doesnt survive /reload, I'd agree

ornate heart
#

Noob question but how does reload break plugins?

wind dune
#

lucksperms survives a reload but throws many exceptions

sullen marlin
#

that doesnt sound like surviving

wind dune
eternal oxide
#

A well written plugin shoudl have no errors nor warnings when you reload

sullen marlin
#

in C:/Users/<name> ?

wind dune
#

oh sorry it was a file

quaint mantle
#

where should I put my *.yml files? In com.name.plugin? Or in SRC?

sullen marlin
#

src

quaint mantle
#

cause I created a folder named "resources" in my src, and created a file named data.yml into the folder, and it's saying FileNotFoundError
InputStream inputStream = new FileInputStream(new File("resources/data.yml"));

#

any reaon ?

#

reason*

#

i'm doingn something wrong?

wind dune
#

What is the source of the problem?

eternal oxide
#

resources folder is not copied into your final jar

quaint mantle
#

but it says file not found error in my IDE

#

i didn't compiled it for now

#

so it's normal ig ?

eternal oxide
#

use getResource

sullen marlin
#

new File would be a resources/ folder in your server

sonic basin
#

the event still doesnt fire

quaint mantle
#

uh

eternal oxide
#

is it annotated and did you register it?

sonic basin
#

annotated?

eternal oxide
#

@Eventhandler

sonic basin
#

oh

#

yes i did

#

wait

#

.

#

i am so stupid

#

and i spent all that time

#

because i forgot to annotate

quaint mantle
#

InputStream inputStream = new FileInputStream(new File.getResource("data.yml"));
like that? data.yml is in my resources folder

sonic basin
#

thanks @eternal oxide

eternal oxide
#

Its good to make mistakes.,

sonic basin
#

yeah

#

because we learn from them

wind dune
sullen marlin
#

did you delete your buildtools folder also?

wind dune
#

yes

round finch
#

how do i make a world generator in 1.16.5? 🤔

sullen marlin
#

same as every other version

wind dune
sullen marlin
#

nope, idk what's wrong with your system

#

did you install git yourself or let bt do it?

eternal oxide
#

if all else fails, delete everythign and start from scratch

wind dune
#

I've installed it myself

sullen marlin
#

    This occurs on Linux (and occasionally Windows) when you have git's autocrlf enabled. To fix, run git config --global --unset core.autocrlf and re-pull/re-run BuildTools.
    On Windows this may occur when using the built-in command prompt (cmd.exe). To fix this, change to a different terminal such as Git Bash.
#

try that

wind dune
#

It looks like it works.

#

Thanks md_5 😄

summer scroll
#

How does ChatColor.of() works?

wind dune
#

If have one more question. The CraftBukkit-Folder contains the NMS source. this is the source of the latest build, isn't it?

drowsy helm
#

wait do you mean valueOf?

summer scroll
#

no, of() it's for the hex color.

eternal oxide
#

so bungee ChatColor

summer scroll
#

nvm, i'm just gonna use some libs instead.

sullen marlin
#

do you have a specific question

#

you put the colour you want as an argument to the method

#

thats how it works

summer scroll
#

I want it so you can define the colors alongside with the message.
For exampe the config would look like this.

messages:
  reload: '&#ff00ff& Reloading &#ffffff& plugin...'
sullen marlin
#

then you need to write a method to translate the &#& format

#

the 'native' format for hex colours is &x&f&f&9&9&9&f&f

drowsy helm
#
 public static String translateHexColorCodes(String startTag, String endTag, String message)
    {
        final Pattern hexPattern = Pattern.compile(startTag + "([A-Fa-f0-9]{6})" + endTag);    
        final char COLOR_CHAR = ChatColor.COLOR_CHAR;
        
        Matcher matcher = hexPattern.matcher(message);
        StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
        while (matcher.find())
        {
            String group = matcher.group(1);
            matcher.appendReplacement(buffer, COLOR_CHAR + "x"
                    + COLOR_CHAR + group.charAt(0) + COLOR_CHAR + group.charAt(1)
                    + COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3)
                    + COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)
                    );
        }
        return matcher.appendTail(buffer).toString();
    }```
summer scroll
#

How can I do that?

drowsy helm
#

xxx

sullen marlin
#

use the code pasted above

summer scroll
#

oh, alright.

#

thanks!

drowsy helm
#

no stress

quaint mantle
#

can someone give me an exemple with loading a convig and saving it cuz i'm trying for like 3 hours and i can't do it

sullen marlin
#

getConfig() saveConfig()

#

its inbuilt

eternal oxide
sullen marlin
#
BukkitWiki

The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...

vivid cave
#

is there a way to LOCK an object to the current thread (only the current thread may read/write into this object, the read/write "requests" from other threads would be added to the queue, and perform on the up to date object after being unlocked), and unlock it at a given time?

#

a bit like synchronized mechanics

ivory sleet
#

ReentrantLock mb?

vivid cave
#

but thing is, it has to do multiple operations

vivid cave
#

i aren't a crack when it comes to multi threading soo

ivory sleet
#

Thing is you don’t need to synchronize reads assuming it’s get methods etc

vivid cave
#

well if you don't synchronise reads, you may read out dated data

#

like cached stuff

ivory sleet
#

?

wide galleon
#

How can I teleport the player into the Nether?

ivory sleet
#

If we’re taking IO then ofc synchronizing maybe good if you’re doing it async

vivid cave
#

i'm doing it async

#

and i need synchronising

ivory sleet
#

You’re operating with IO?

drowsy helm
ivory sleet
#

Or just normal objects?

#

Like in-memory ones

vivid cave
#

well i'm operating with itemstacks metadta

ivory sleet
#

Uhm how come this is async

drowsy helm
#

should reentrant declaration do what you want?

vivid cave
#

my side thread keeps constantly editing the metadata of it

#

(animated color armor)

#

while my main thread may change their meta data

drowsy helm
#

you can do that on the main thread

vivid cave
#

no i don't want to

ivory sleet
#

Aim for a more immutable design

#

It will solve the problem in a more elegant way rather than having to synchronize the shit out of it

quaint mantle
#

it says .getConfig will create a folder if there is no folder but it doesn't create a folder for me

sullen marlin
#

probably saveConfig

vivid cave
#

give examples of what i could do

quaint mantle
#

and it says "plugin.getConfig" but i'm using "this.getConfig" in my Main.java

vivid cave
#

i'm out of ideas

quaint mantle
#

normal right?

eternal oxide
#

I think first time is saveDefaultConfig() saves the config and creates the folder if it needs to

sullen marlin
#

yes

ivory sleet
#

Don’t mutate the itemmetas just cache them and reuse them

vivid cave
#

but it doesn't save my problem does it, i need to make the cached itemmetas "synchronized" at least

ivory sleet
#

No you don’t

#

But if you want just wrap every usage of it with synchronized(itemMetaInstance) {}

quaint mantle
#

so I should put this.saveConfig() in my onDisable right?

ivory sleet
#

But it will be kinda slow and sloppy

#

And it’s a bad design

drowsy helm
#

if your server crashes or your server dies you lose however many hours of data

quaint mantle
#

oh yeah okay

#

ty

#

how can I modify information

#

is set gonna modify a key if it already exists?.

drowsy helm
#

yes

quaint mantle
#

ok rt

#

ty

drowsy helm
#

nw

quaint mantle
#

what .get gonna return if the key doesn't exists

drowsy helm
#

it will return null

#

or if a number, will return 0

vivid cave
# ivory sleet Don’t mutate the itemmetas just cache them and reuse them

if i just reuse them without any synchronisation, this may happen:
initial ItemMeta: [Section0,Section1,Section2] (this is just a scheme)

Thread A: Starts to write into Section1 of ItemMeta (imagine this writing process is quite long)
Thread B: Starts to write into Section2 of ItemMeta
Thread B: Finishes writing into Section2; ItemMeta is now ItemMeta*: [Section0,Section1,Section2*]
Thread B: Put ItemMeta*into ItemStack
Thread A: Finishes writing into Section1; ItemMeta is now ItemMeta**$:[Section0,Section1$,Section2]
Thread A: Put ItemMeta
$** into ItemStack

See the problem here is that the item received the ItemMeta [Section0,Section1**$,Section2] instead of [Section0,Section1$**,Section2*], because of how setItemMeta works (rewrites all the section unfortunetely, not the changed ones only)

ivory sleet
#

To be fair this entire multithreading with ItemStack is an over engineering move

#

You could have a single thread producing and preparing ItemStack or itemmetas. But rn you’re just complicating it for no big reason

vivid cave
haughty haven
#

hey guys I'm super new to coding but got some javascript experience in the past and I've recently gotten into it again! I don't know where to get help for my current issue (it's not that big but I've been stuck on it for an hour), so sorry if I've bulged into anything!

eternal oxide
#

?ask

queen dragonBOT
#

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.

haughty haven
#

okie dokkie! I will type it out nnow

ivory sleet
#

Alexis I mean even so you don’t need to do everything async

#

If you’re downloading something for instance then it’s more plausible

haughty haven
#

So basically, I want to make it so when the player right clicks an item, stuff happens. I've gotten that to work, however I now want to make it so that the item gets consumed. I've gotten it to work in the main hand, however I can't get it to work in the off-hand.

#
                    corny.setAmount(corny.getAmount()-1);
                    player.getInventory().setItemInMainHand(corny);
                    player.updateInventory();```
eternal oxide
#

getItemInOffHand

#

check if its the correct item

haughty haven
#

I've also got this code to check if the item is the specific thing:
if (event.getItem().getItemMeta().equals(ItemManager.corn.getItemMeta()))

vivid cave
#

well rn i'm doing it 100% sync, it works pretty good when not too many multi color armor are created, but if we make a room full of armor stands, i could experience few lag

#

at all cost, i want this feature to not take over the main thread tbh

#

not only performance wise

#

but concept wise too

#

i don't like knowing the fact that there is sth that can potentially tank my main thread, where all stuff that is technically more "important" than that has to happen, like dispatching events

ivory sleet
#

Hmm yeah that’s true on the contrary

eternal oxide
#

I can;t see that you have so many items that updating them every 2 ticks is going to tank anything

ivory sleet
#

But I thought you could save yourself by producing the stacks on start up and then cache them then and there for later usage. Then you ultimately wouldn’t need to do all of this synchronization over itemmetas etc

haughty haven
# eternal oxide getItemInOffHand

I'm not quite sure how to do it, this is what I got. I just used my old code from before
if(player.getInventory().getItemInOffHand().equals(ItemManager.corn.getItemMeta()))

eternal oxide
vivid cave
#

well Thread A and Thread B keep changing the item metas, Thread A is doing it very rarely, but still (minor stuff), Thread B is changing it every 1 or 2 ticks

haughty haven
#

so what should I compare it to? Just the itemstack

eternal oxide
#

no, get the meta to compare

haughty haven
#

ohhh right

ivory sleet
#

You should be working with immutability if you can, that will give you free thread safety

#

But even so no multithreading is needed in your case

vivid cave
olive badger
#

Hello, i re up my gradle issue because i still havent found an solution

haughty haven
# eternal oxide You are comparing the item to meta. Won;t work

I've gotten it to work using if statements

                        ItemStack cornyleft = player.getInventory().getItemInOffHand();
                        cornyleft.setAmount(cornyleft.getAmount()-1);
                        player.getInventory().setItemInOffHand(cornyleft);
                        player.updateInventory();
                    }
                    if(player.getInventory().getItemInMainHand().getItemMeta().equals(ItemManager.corn.getItemMeta())) {
                        ItemStack corny = player.getInventory().getItemInMainHand();
                        corny.setAmount(corny.getAmount()-1);
                        player.getInventory().setItemInMainHand(corny);
                        player.updateInventory();
                    }```

however, only the first if statement that comes first works
round finch
#

i wanna be able to make a minecraft alpha generator but i don't have the math🤔

quaint mantle
#

I have issues with importing the mythicmobs api

summer scroll
haughty haven
#

nope, using getAction

summer scroll
#

ahh, I thought you're trying to do something If the player consumes an item.

quaint mantle
#

How can I import mythicmobs api?

haughty haven
#

yeah nah, if a player right clicks with a specific custom item on a block/in the air: stuff happens

#

but I'm having trouble to also make it lose one item

#

because people can abuse it by right clicking it in their off-hand and it won't consume anything

summer scroll
haughty haven
#

i'm just having troubles making it check for both hands

summer scroll
#

What happens If they're holding the items on both hands lmao.

haughty haven
#

shit

eternal night
#

Isn't the PlayerInteractEvent called twice for both hands ?

summer scroll
#

You might want to make it only works on main hand I guess.

haughty haven
#

yea, that'd be easier

haughty haven
drowsy helm
#

it annoys me that HashMap#forEach gives a entryset instead of a bi consumable

#

wait i lied

summer scroll
haughty haven
#

but the problem is that if player holds custom item in both hands, it uses both items and consumes 2 of it

summer scroll
#

You need to check the hand.

haughty haven
summer scroll
#

So PlayerInteractEvent will fires 2 times for each hand, the main hand and offhand.

quaint mantle
#

How do u summon an entity in spigot?

quaint mantle
#

weird

#

javadoc starts making sense

quiet ice
#

Ignore the "or null if unsuccessfull" and @NotNull annotation

haughty haven
#

thanks bruv

summer scroll
summer scroll
#

Does anyone know why PlayerTeleportEvent got called twice?

#

I'm teleporting player using player.teleport() and I debug the location and the cause.

#
[18:09:32 INFO]: aglerr issued server command: /back
[18:09:32 INFO]: Saved: world1, 12, 71, 4, Cause: PLUGIN
[18:09:32 INFO]: Teleported: world1, 8, 71, 19
[18:09:32 WARN]: aglerr moved too quickly! -3.895643358226959,0.0,14.772120363541665
[18:09:32 INFO]: Saved: world1, 8, 71, 19, Cause: UNKNOWN
regal dew
#

you sure ur not teleporting them not twice

summer scroll
#

Yes, it happens when there is a warning about player moved too quickly.

#

I guess they're getting teleported back.

weak kayak
#

Yeah probably them getting teleported back when they move too quickly

regal dew
#

guess the event would be fired when they are set back as well

weak kayak
#

Unless that doesn't call PlayerTeleportEvent

#

I'm gonna check the docs

summer scroll
#

I don't always get the warn.

weak kayak
#

Does it call PlayerTeleportEvent when you don't get the warn?

summer scroll
#

Yeah I think they got teleported back and fires the event.

#

With cause UNKNOWN.

regal dew
#

but if youre teleporting the player already, why do you want to listen on PlayerTeleportEvent anyway? you know already when the player is teleporting right

weak kayak
#

Alright so you gotta check if the cause is UNKNOWN and you're good to go I believe

summer scroll
#

I want to store the "from" location for /back command.

regal dew
#

but you can just get the location from the player?

#

player.getLocation() before you teleport

#

it returns a fresh new copy of the location

summer scroll
#

I want to also get the location If the teleportation is done by other plugin.

regal dew
#

ah, yes, then just check the cause

weak kayak
#

If the cause is PLUGIN then save the location?

regal dew
#

there's a cause PLUGIN :)

summer scroll
#

Yeah, i guess i'm just gonna check the cause.

#

Thanks guys.

weak kayak
#

Np

quaint mantle
#

how can I make custom crafts

#

like when you put x and x items in a crafting table it makes a custom blocks or something

dusky lynx
#

ShapedReciped

sonic basin
#

is there a way to change a value of a variable from a class to another class

#

specifically from commands to events

quaint mantle
#

how to cancel the breaks of crops when we jump in

#

using events or something

#

so i can say "if it has special boots, then dont break it"

ancient plank
lost matrix
sonic basin
#

i mean i do have some experience in java i know most of the basics

lost matrix
# sonic basin fair enough

Then its just one more step 😄
So you need to understand 2 more things
What is an instance
What is a constructor

sonic basin
#

all i know is that i have to make the variable a public one

#

ok got it

lost matrix
sonic basin
#

k

quaint mantle
#

Suddenly, some another class is not called, and with a red underline, it says "Cannot resolve symbol ...". But the build works well and the plugin works well.

hoary nebula
#

where to start

lost matrix
#
  1. Naming conventions. totoServerPlugin -> TototServerPlugin
hoary nebula
#

an ide

quaint mantle
#

oh ok

quaint mantle
lost matrix
hoary nebula
#

what should i learn

#

where to start

quaint mantle
#

Sadly, It says "No Suggections"

hoary nebula
#

i see

quaint mantle
hoary nebula
#

yea

quaint mantle
#

wdym

lost matrix
quaint mantle
#

ah

hoary nebula
#

i know php

ivory sleet
#

😮

quaint mantle
#

then you can make pe plugin

#

🙂

lost matrix
hoary nebula
#

pe

#

did that already

ivory sleet
#

the legendary language

hoary nebula
#

wanted to try java

hoary nebula
summer scroll
#

Is passing a map through constructor a bad thing?

lost matrix
hoary nebula
#

what's the difference between java and pe

lost matrix
quaint mantle
summer scroll
ivory sleet
#

You can try restart and invalidate caches

lost matrix
hoary nebula
#

oop!

quaint mantle
#

yea, but I don't really know what is problem

#

I can't just import main class

#

and another class

#

"Cannot resolve symbol"

lost matrix
quaint mantle
#

hmm, okay i'll try

#

I have a code from a few days ago, can it make it easier to find errors?

hoary nebula
#

you're using an ide

ornate heart
summer scroll
lost matrix
# summer scroll I currently have something like this. ```java private final BackCommand plug...

You should not pass collections like that to other classes. Best practice would be a
PlayerLocationTracker class of which you have one single instance.
This manager class has methods like "setLastPosition(Player player, Location location)"
and "teleportPlayerToLastPosition(Player player)" and so on. And the command has the singleton instance
as well as the listener. And both just delegate their data to the manager that handles everything.

summer scroll
#

Alright.

#

So make an object basically?

lost matrix
ornate heart
#

Gotchu

lost matrix
# summer scroll So make an object basically?

Yes create a "PlayerLocationTracker" class of which you create one single instance on startup. This holds your data structure (Map<UUID, Location>)
And provides methods to other classes to manipulate the map or apply functions on its content. Dont expose the Map to other classes. If you need new
functionality then your PlayerLocationTracker just gets a new method.

quaint mantle
hoary nebula
#

😥

lost matrix
quaint mantle
quaint mantle
lost matrix
quaint mantle
#

I didn't tried anything, i'm here to know how can I do

lost matrix
quaint mantle
#

so, on playerinteractevent trigger, i'm checking for "physical", and if it's true, I replant the crop breaked, else I don't do anything?

lost matrix
#

Then get the clicked block and check if its soil. Cancel the event if those two conditions are met.

summer scroll
lost matrix
summer scroll
#

I was about to name it like put and remove lmao.

lost matrix
#

The methods should look like this:
"setLastPlayerLocation(UUID playerID, Location lastLocation)"
"teleportPlayerToLastLocation(Player player)"

summer scroll
#

Alright, I'll show you the class once completed.

quaint mantle
#

is Physical an action?

#

so I do event.getAction().equals(PHYSICAL) ?

lost matrix
#

Its an action

#

But that line is not valid java

quaint mantle
#

how can I do then?

#

i through we were making it like this

#

what should I change?

hoary nebula
#

conditions

quaint mantle
#

if (event.getAction().equals(PHYSICAL) == true)

#

like this?

cinder thistle
#

@quaint mantle

#
final Mom mom = new Mom();
Dad dad = new Dad();

dad.fuck(mom);

if (!mom.isPregnant()) {
    mom.liveGoodLifeWith(dad);
    dad.liveGoodLifeWith(mom);
    return;
}

dad.leave();
Son son = mom.giveBirth();

new Thread() {
    @Override
    public void run() {
        Thread.sleep(2.365e+10); // Nine months later
        System.out.println(mom.isEmpty());
    }
}.start();
false

Why is this not working

#

fix code or bad

lost matrix
quaint mantle
cinder thistle
#

maybe if I try mom.kick(KickType.STOMACH);

quaint mantle
#

k

quaint mantle
quaint mantle
fathom timber
#

Lmfao

quaint mantle
#

i forgot a ) ig?

hoary nebula
#

nono

lost matrix
quaint mantle
#

aaaa ty

hoary nebula
#

also no need to actually equalize it i think

#

or idk

#

dk anty java

#

😞

quaint mantle
#

so if it's physical i'm cancelling the event? or I just replant the crops?

lost matrix
quaint mantle
#

thanks

lost matrix
summer scroll
#

And also, should I make the thing final on startup?

#

private final PlayerLocationTracker ...

lost matrix
summer scroll
#

Oh okay, I thought it will throw an NPE or something.

lost matrix
mystic plinth
#

Hello, can anyone point me out a guide on how to use NMS?

summer scroll
chrome beacon
ivory sleet
mystic plinth
#

Yeah I should have been more specific, I need help for adding it to the project, not for dev

chrome beacon
#

ah are you using maven or gradle?

ivory sleet
#

Just add the spigot jar as a dependency Insane, but as Olivo said it will be significantly easier to do with either gradle or maven

mystic plinth
#

Maven in IntelliJ with minecraft-dev plugin

chrome beacon
#

Alright replace spigot-api with spigot

#

and run buildtools

quaint mantle
#

what getLeggings() returns if there is not an legging on

chrome beacon
#

null

mystic plinth
#

Now, how can I replace spigot-api in Intellij?

chrome beacon
#

In your POM

#

Replace spigot-api with spigot

mystic plinth
#
    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.16.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

This?

chrome beacon
#

Yes now change the artifact id from spigot-api to spigot

mystic plinth
#

And where should I put the spigot jar?

chrome beacon
#

You don't need to do anything with it

#

BuildTools puts it in your local maven repo for you

mystic plinth
#
    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.16.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

So, BuildTools --rev 1.16.1
then change the pom, reload maven changes and done?

chrome beacon
#

Yeah done

olive badger
#

i think i just finish to go back to maven, i really don't find an same issue of me 😦
And just say fuck to gradle (again)

mystic plinth
quaint mantle
#

why is ShapedRecipe deprecated?

#

in eclipse it says that ShapedRecipe has @Deprecated

earnest junco
quaint mantle
#

ty

#

ItemStack item = new ItemStack(Material.LEATHER_BOOTS);
        ItemMeta meta = item.getItemMeta();

meta.setDisplayName(ChatColor.GREEN + "Farming Boots");
        item.addUnsafeEnchantment(CustomEnchants.FARM, 1);
        
        NamespacedKey key = new NamespacedKey(this, "farming_boots");

        ShapedRecipe recipe = new ShapedRecipe(key, item);

        recipe.shape(" E ", " E ", " S ");

        recipe.setIngredient('E', Material.HONEY_BOTTLE);
        recipe.setIngredient('S', Material.LEATHER_BOOTS);

    Bukkit.addRecipe(recipe);
#

anyone know why when i'm crafting it i don't get the name

quaint mantle
#

i just did the exemple

#

bruh

#

?

#

wasnt replying to you

#

ah okay

quaint mantle
#

item.setItemMeta(meta);

#

ah yes thanks

woven coral
#

https://sourceb.in/mAaFMcY5bd - here's the code.
https://sourceb.in/tWYLE95Xu5 - heres the yml.

Error:
Basically what it's doing, is not checking if the player's inventory contains both of the materials and they're amounts correctly, what I mean is that in the config it is set that I need 20 diamond blocks AND 20 gold blocks, but if I have 10 diamond blocks and 20 gold blocks, the code will still run.

quaint mantle
#

you could've just sent the code here

#

nevermind.

#

that is way bigger in text than it seems.

woven coral
#

plus its easier to read via link

quaint mantle
earnest junco
#

you can

woven coral
#

i can

#

I dont think you read my problem right

tribal sparrow
#

can anyone help me understand why PlayerJoinEvent is being fired twice?
[23:19:11 INFO]: [Pirates] [Debug] CALLED playerJoinEvent();
[23:19:11 INFO]: [Pirates] [Debug] CALLED playerJoinEvent();

    @EventHandler
    public void playerJoinEvent(PlayerJoinEvent event) {
        getPlugin().getDatabaseManager().loadPlayer(event.getPlayer());
        getPlugin().sendDebugMessage("CALLED playerJoinEvent();");
    }```
quaint mantle
woven coral
#

since rn

quaint mantle
#

no YAML parser has ever done that for me

#

also its unneccessary and unconventional

woven coral
#

welp

#

you learned something new

earnest junco
woven coral
#

since my command thingie works

woven coral
quaint mantle
#
                        ConfigurationSection section1 = plugin.getConfig().getConfigurationSection("quests." + (plugin.questData.getQuestNPCName(p.getUniqueId()) + ".") + (plugin.questData.getQuestName(p.getUniqueId()) + ".") + "neededSupplies"); // get's the quests needed supplies
                        section1.getKeys(false).forEach(key -> { // gets all the keys in the needed supplies
                            ConfigurationSection section = plugin.getConfig().getConfigurationSection("quests." + (plugin.questData.getQuestNPCName(p.getUniqueId()) + ".") + (plugin.questData.getQuestName(p.getUniqueId()) + ".") + "neededSupplies." + key);
                            section.getKeys(false).forEach(item -> {
                                Material material = Material.valueOf(plugin.getConfig().getString("quests." + (plugin.questData.getQuestNPCName(p.getUniqueId()) + ".") + (plugin.questData.getQuestName(p.getUniqueId()) + ".") + "neededSupplies." + (key + ".") + "material"));
                                int amount = plugin.getConfig().getInt("quests." + (plugin.questData.getQuestNPCName(p.getUniqueId()) + ".") + (plugin.questData.getQuestName(p.getUniqueId()) + ".") + "neededSupplies." + (key + ".") + "amount");
                                ItemStack itemStack = new ItemStack(material, amount);
                                for (ItemStack item1 : p.getInventory().getContents()) {
                                    if (item1 != null) {
                                        if (item1.equals(itemStack)) {
                                            p.getInventory().removeItem(item1);
#

this is just pain

woven coral
#

i will

#

I'll actually use the sections to get the stirngs

#

so it'd look nicer

earnest junco
woven coral
#

can you show an example of what you mean? since I don't know which type of for you are talking about

quaint mantle
#

how to read an java error? Like it just says Caused by: java.lang.NullPointerException

proper notch
#

The stack trace will show what it's caused by

#

if you send the error you're getting and I'll explain through it

quaint mantle
#

org.bukkit.command.CommandException: Unhandled exception executing command 'save' in plugin SFX v1.0

proper notch
#

The actual entire error

quaint mantle
#

[16:24:19] [Server thread/ERROR]: null

#

omg

#

i can't event send the error

proper notch
#

Just send your log

quaint mantle
#

it's too big

#

yes

proper notch
#

?paste

queen dragonBOT
quaint mantle
proper notch
#
Caused by: java.lang.NullPointerException
        at com.sfx.ayo.Main.onCommand(Main.java:119) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot.jar:3029-Spigot-79d53c2-e9ad7cb]
        ... 19 more```
#

This is the part that's important

quaint mantle
#

mhm

proper notch
#

So what that basically mean is the NullPointerException originated from the Main class, inside the method onCommand and on line 119

woven coral
#

and smth is null

quaint mantle
#

119 is a }

#

:D

woven coral
#

that also means that the value is nothing

earnest junco
#

@woven coral You honestly wanna convert it to a list of itemstacks, so yo can do

for (ItemStack itemStack : itemStackList)
    if (!inventory.containsAtLeast(itemStack, itemStack.getAmount())) return;

for (ItemStack itemStack : itemStackList)
    inventory.removeItem(itemStack);
proper notch
#

You've probs changed it since then

quaint mantle
#

no

#

i didn't changed it

#

and the 119 line is just a }

proper notch
#

I don't think the JVM messes up that bad with errors

quaint mantle
#

and in 118 there is a return;

tribal sparrow
#

can anyone help me understand why PlayerJoinEvent is being fired twice?
[23:19:11 INFO]: [Pirates] [Debug] CALLED playerJoinEvent();
[23:19:11 INFO]: [Pirates] [Debug] CALLED playerJoinEvent();

    @EventHandler
    public void playerJoinEvent(PlayerJoinEvent event) {
        getPlugin().getDatabaseManager().loadPlayer(event.getPlayer());
        getPlugin().sendDebugMessage("CALLED playerJoinEvent();");
    }```
proper notch
#

Can you send your entire main class please .$

woven coral
quaint mantle
proper notch
#

That error is definitely from a different version of the code

quaint mantle
#

i have 2 other file and they don't have more than 70 lines

proper notch
#

Just try updating whatever you're running on the server. You might've accidentally imported something new

quaint mantle
#

uh?

#

what do you mean

proper notch
#

That error is definitely not from that code

quaint mantle
#

im gonna restart my server

#

btw

#

why we can't send pictures

#

thats weird

proper notch
#

Verify to send images

round finch
cinder thistle
#

u right

#

that's probably it

round finch
quaint mantle
#

same error

proper notch
#

Can you send the JAR file of the plugin that you're running on the server

cinder thistle
#

lol

earnest junco
# woven coral https://sourceb.in/dv4HxsDCHF - basically like this? EDIT: doesnt work regardle...

Because the code is still the same. First you convert your ENTIRE list of needed materials to an actual list.

List<ItemStack> itemStackList = new ArrayList<>();
neededSuppliesSection.getKeys(false).forEach(key -> {
    itemStackList.add(
        new ItemStack(
            Material.matchMaterial(neededSuppliesSection.getString(key + ".material")),
            neededSuppliesSection.getInt(key + ".amount")
        )
    );
});

// And then what I sent before
onyx shale
#

lol x2

quaint mantle
#

okay rn it worked

#

but I have another problem

#

by making my ShapedRecipe, I said to add an unsafe enchantment, and it doesn't add the enchant to the item

ItemStack item = new ItemStack(Material.LEATHER_BOOTS);
        ItemMeta meta = item.getItemMeta();
        item.addUnsafeEnchantment(CustomEnchants.FARM, 1);
        
        meta.setDisplayName(ChatColor.GREEN + "Farming Boots");
        List<String> alLore = new ArrayList<String>();
        alLore.add(ChatColor.GOLD + "Farm X");
        meta.setLore(alLore);
        item.setItemMeta(meta);
        
        NamespacedKey key = new NamespacedKey(this, "farming_boots");

        ShapedRecipe recipe = new ShapedRecipe(key, item);

        recipe.shape(" E ", " E ", " S ");

        recipe.setIngredient('E', Material.HONEY_BOTTLE);
        recipe.setIngredient('S', Material.LEATHER_BOOTS);

        Bukkit.addRecipe(recipe);

Here is my code, and the FARM enchant doesn't work

#

it not in the boot

#

like the boot 1) doesn't have the purple animation, and the enchant doesn't work

#

i'm not getting any erros

round finch
#

i were wondering what the numbers was for the default Alpha Generation terrian

#

noise and etc

woven coral
#

now it doesnt work entirely

#

alr i think i know why

quaint mantle
#

anyone know why meta.setDisplayName and item.setItemMeta delete an custom enchant?

mystic plinth
#

How can I get a block state id for a packet?

vital swift
#

Is there event for NPC interact?

#

i've made this npc

onyx shale
#

and i guess its through packets?

olive lance
#

@quaint mantle because the item meta is what the custom enchant plugin used to know it’s enchanted

#

PlayerInteractEntityEvent @vital swift

vital swift
olive lance
#

It didn’t work?

vital swift
#

yea

#
    public void onInteract(PlayerInteractEntityEvent event) {
        Bukkit.broadcastMessage("Interacted!");
        Entity clickedEntity = event.getRightClicked();
        if (clickedEntity instanceof Player) {
            Bukkit.broadcastMessage(clickedEntity + "2");
        } else {
            Bukkit.broadcastMessage(clickedEntity + "a");
        }
    }```
#

it won't even broadcast interacted

olive lance
#

Does your plugin handle any other events properly

#

Or is it only that one

vital swift
#

its the only plugin i have

young knoll
#

Client side entities won’t trigger the event

quaint mantle
#

how to make an item unbreakable

olive lance
#

That is client side?

quaint mantle
#

like itll never get break

#

or lose durability

vital swift
olive lance
#

Unbreaking 1000 does the trick

quaint mantle
#

yu

#

ty*

young knoll
olive lance
#

Lol

brittle nova
#

When I pull the lever it changes to air but when I pull it again it doesn't change to oak_planks. Can somebody help me with this?

summer scroll
#

Is it possible to have a command suggestion with the description?

#

Instead of just about, is it possible to have it like this?
about - showing version or something like that (command - description).

young knoll
#

You probably need to hook into brigadier

drowsy helm
#

getting The found tag instance cannot store String as it is a NBTTagByte when setting a PDC despite me always setting it as a string :hmm:

ivory sleet
#

Maybe you’re searching for commodore

quaint mantle
#

cleaner

#

imo atleast

drowsy helm
#

jesus

#

why hard code it

quaint mantle
#

if (block.isBlockPowered()) {
...
}else if(!block.isBlockPowered()){

#

cmon