#help-development

1 messages ยท Page 1348 of 1

ivory sleet
#

GetNo

cloud berry
#

then there's d .-. do we talk about d

lost matrix
#

I mean C# has some very very nice features. Like delegates. Or the fact that there is not type erasure of generics.

cloud berry
#

LOL

lost matrix
#

But i also dont like the conventions of C#...

#

But you cant tell me that anyone writing Java understands this:

quaint mantle
#

how would i call multiple events in a method

lost matrix
#

But thats more C than C++

lost matrix
quaint mantle
#

well

#

For example, a combat log plugin

onPlayerPunch {

onPlayercommand.cancel
onPlayerlogout.kill

}

paper viper
#

??

cloud berry
#

bruh wot

quaint mantle
#

its not real java code its just an example

cloud berry
#

@quaint mantle hold up i show u how its done

quaint mantle
#

Ok

eternal oxide
#

You don;t call events, you listen to them

pulsar schooner
#

I think he wants it to be when a player is punched if they combat log they die and they can't run commands

quaint mantle
lost matrix
# quaint mantle Yeah

Oh ok. Then go with what aglerr told you.
Tag the player. You can use the scoreboard tags for that.

pulsar schooner
#

So, when the player is punched, put the player in like an array list, and listen for other events, and if the player from that event is in the array list cancel the event

quaint mantle
#

ah

pulsar schooner
#

And then remove them when you don't want them tagged

#

That's important

summer scroll
cloud berry
#
    public void onPlayerPussyPvp(PlayerCombatLogEvent event)
    {
        Player player = event.getPlayer();
        if (player.getWorld().getUID().equals(Plugin.ArenaMan.ArenaWorld))
        {
            UUID uid = player.getUniqueId();
            tellEverybody(player.getName() + " is a b**ch");
        }
    }```
^ u need pvpmanager plugin api for this to work doe
quaint mantle
#

ty

lost matrix
#

This would be an example for tagging:

  private static final String COMBAT_TAG = "_IN_COMBAT_";

  public void tagPlayer(final Player player) {
    player.getScoreboardTags().add(COMBAT_TAG);
  }

  public void unTagPlayer(final Player player) {
    player.getScoreboardTags().remove(COMBAT_TAG);
  }

  public boolean isTagged(final Player player) {
    return player.getScoreboardTags().contains(COMBAT_TAG);
  }
pulsar schooner
#

You don't need to use scoreboards!! Overcomplicated

cloud berry
#

๐Ÿ˜ฎ oh shit wut are those

quaint mantle
#

ah yeah

cloud berry
#

waaaaaaaaat

#

u serious

#

u can just define custom steve tags

#

player variables?

pulsar schooner
#

Scoreboards are too complicated you don't have to use those

cloud berry
#

looks simple enough

lost matrix
pulsar schooner
#

Ig if you think so

cloud berry
#

i thought scoreboard was that display on the right side of screen that some servers have

pulsar schooner
#

Store uuids in an arraylist

lost matrix
#

and remove

#

And no persitence

#

The ScoreboardTags are persistent

pulsar schooner
#

Why would it need to persist after a restart if it's a combat log prevention plugin?

#

They are not in combat after a restart lol

lost matrix
cloud berry
#

๐Ÿ˜ฎ ok i didnt think of that 1, smart

pulsar schooner
#

I guess...

#

Yea me niether

blazing bronze
#

Apologies. Resending this message as I forgot to add other bits of code..

Does anyone know how to fix a player skull being off center on the block it was placed?

The issue:

The code:

    public static void setBlockToCoconut(Location location, String texture) {
        Block block = location.getBlock();
        block.getChunk().load();
        block.setType(Material.SKULL);
        changeSkin(block, texture);
    }
    
    public static void changeSkin(Block b, String texture) {
        if (b.getType() == Material.SKULL) {
            Skull skull = (Skull) b.getState();
            skull.setRotation(BlockFace.SOUTH);
            skull.setOwner("Demonly");
            skull.setSkullType(SkullType.PLAYER);
            GameProfile profile = new GameProfile(UUID.randomUUID(), null);
            byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", texture).getBytes());
            profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
            try {
                Field profileField = skull.getClass().getDeclaredField("profile");
                profileField.setAccessible(true);
                profileField.set(skull, profile);
            } catch (NoSuchFieldException | IllegalAccessException e) {
                e.printStackTrace();
            }
            skull.update(true);
        }
    }
cloud berry
#

chat = :nuke:

rapid vigil
#
    public void onBreak(BlockBreakEvent e) {
        Player p = e.getPlayer();
        if(!p.hasPermission("break.break"));
        e.setCancelled(true);

    }
    @EventHandler
    public void onPlace(BlockPlaceEvent e) {
        Player p = e.getPlayer();
        if(!p.hasPermission("place.place"));
        e.setCancelled(true);
    }
}``` Hey, can anyone help.. Even If I had the permission I can't break / place
cloud berry
#

yall need to use

#

?paste

queen dragonBOT
pulsar schooner
#

^^

pulsar schooner
cloud berry
rapid vigil
summer scroll
rapid vigil
narrow furnace
#

No

blazing bronze
steep nova
#

I believe

cloud berry
#

@rapid vigil remove semicolon at end of if and for the love of god start reading ur ide's warnings

cloud berry
rapid vigil
#

Sorry...

cloud berry
#

ide warnings cover shit like this lol

narrow furnace
#

are you using an ide

#

a java ide

lost matrix
steep nova
pulsar schooner
#

Eclipse says if statements with semicolons are ok btw

#

At least for me

cloud berry
rapid vigil
cloud berry
#

mighta been somethin else LOL if so nvm poreyy

pulsar schooner
#

); no work

narrow furnace
#

{} is a block

#

); is end of statement

#

; is end of statement even

rapid vigil
#

oh, So It won't read the "set.Cancelled(true):" ?

pulsar schooner
#

Nope

rapid vigil
#

and { will read the under line?

round finch
#

eyy guys i'm having a little problem

then i loop storage enchants it loops every past enchant for example
i combined enchants on enchant book 2 times x 4 sharpness and... i want sharpness 5 enchant

pulsar schooner
#

Yes

narrow furnace
#

it will but even if the If is false

rapid vigil
#

Thanks for help a lot, I appreciate that

round finch
#

i want the combind enchant number any easy way to do this?

graceful oak
#

Hey guys I have a plugin that runs off a Map of objects that gets saved to a file when the server shuts down. One problem I have ran into is when the server is forced close I lose all the data on the map because it wasnt shut down and didnt call the on disable. Is this something that a server can go through or is this only something I can do locally. Also if it is something that I need to watch for would the solution be a timed backup of everything that gets recorded every hour or so?

pulsar schooner
round finch
#

thread auto save?

quaint mantle
#

what arguments does tagPlayer take in?

        player.getScoreboardTags().add(COMBAT_TAG);
    }

    public void unTagPlayer(final Player player) {
        player.getScoreboardTags().remove(COMBAT_TAG);
    }

    public boolean isTagged(final Player player) {
        return player.getScoreboardTags().contains(COMBAT_TAG);
    }
    @EventHandler
    public void onLogOut(PlayerQuitEvent event) {
        Player player = event.getPlayer();
        if (tagPlayer() = true) {
            
        }
        

    }```
pulsar schooner
#

A player

daring sierra
#

?paste

queen dragonBOT
daring sierra
#

Please

pulsar schooner
#

And yes please use paste

quaint mantle
#

ok

pulsar schooner
#

And it says what args it takes...

#

In the ()

narrow furnace
#

spigot uses java btw

#

so if ur making spigot plugins

quaint mantle
#

I put Player player = event.getPlayer
and tagPlayer(player) doesn't work

narrow furnace
#

u kinda have to know java..

summer scroll
blazing bronze
blazing bronze
round finch
quaint mantle
#

yeah thats my current plan of action

candid galleon
#

Set would likely be better

#

and UUIDs instead of the player object

lost matrix
latent talon
#

how can I use a PlaceholderAPI placeholder in the a field/b field of the tablist?

I've tried several different methods, but can't figure it out.

round finch
lost matrix
latent talon
#

i know

#

hold on

lost matrix
lost matrix
round finch
summer scroll
#

It kinda have a same concept with ArrayList.

lost matrix
latent talon
# lost matrix You need to parse the String and let PlaceholderAPI replace the placeholder. The...
      // Placeholders class
    private static Player player;
    public static void setPlayer(Player player) {
        GetPlayerCount.player = player; 
    }
    
    public static String bungeeCount() {
        String bungeecount = "%bungee_total%";
        return PlaceholderAPI.setPlaceholders(player, bungeecount);
    }
      // Tablist class 
      b.set(packet, ".....Network: " + Placeholders.bungeeCount)
}

I have something like that, doesn't hook, the player thing i've added was a test which didn't work (it's called on PlayerJoinEvent and it adds the latest player as the player as a test, which did not work

#

the b set is in a ChatComponentText

#

its just simplified

lost matrix
latent talon
#

Yeah

#

It works with Citizens

lost matrix
latent talon
#

yeah

#

every 10 ticks

lost matrix
latent talon
#

should be replacing yeah

#

let me try to see if it is replacing

latent talon
rapid vigil
#

How do I make 2 permissions for a command

latent talon
#

if(player.hasPermission(x) && player.hasPermission(y))

rapid vigil
#

No I want or

#

nvm

latent talon
#

Then do ||

rapid vigil
#

||

#

Yeah thanks.

#

if(!sender.hasPermission("tp.tp" || !sender.hasPermission("tp.tps")))

#

That gives me error

dusky lynx
#

Your missing a ) after the first permission

#

if(!sender.hasPermission("tp.tp") || !sender.hasPermission("tp.tps"))

#

Try that

lost matrix
latent talon
rapid vigil
#

Thanks 7smile7!

lyric grove
#

anyone know how i would fix this?

lost matrix
outer crane
#

dont use legacy components

lyric grove
outer crane
#

mfw not even using Components

lyric grove
#

me?

outer crane
#

you should be using bungee api components

#

what you are using has been depricated by mojang since 2012

lyric grove
#

bungee? what

#

im making a spigot plugin

outer crane
#

i would recommend kyori/adventure but you should at least use BaseComponents

#

a bit of the bungee api is in spigot

lyric grove
#

sorry i dont understand what you mean, im not making a bungee plugin

lost matrix
lyric grove
lost matrix
# lyric grove

Remove the ) after the &e" then add it at the end of the line

lyric grove
#

thanks

graceful oak
#

Hey guys Ive been trying to look online how to solve this issue and I cant seem to find anything on it. I would assume I need to download the latest jar and throw it somewhere in the plugin but I dont know where exactly it is stored in the plugin files. Will anyone be able to help me out?

[11:10:24 WARN]: [NBTAPI] [NBTAPI] The NBT-API at 'package de.tr7zw.nbtapi' seems to be outdated!
[11:10:24 WARN]: [NBTAPI] [NBTAPI] Current Version: '2.6.0' Newest Version: 2.7.1'
[11:10:24 WARN]: [NBTAPI] [NBTAPI] Please update the nbt-api or the plugin that contains the api!
lost matrix
graceful oak
#

No

#

I just get that error when the plugin is on the server and it loads up

lost matrix
#

Your own plugin?

graceful oak
#

yes

#

oh wait maybe its not

lost matrix
#

Do you have any dependencies of which one depends on NBTAPI? You can look that up by showing the dependency tree

graceful oak
#

ok I see its a different plugin its not on loadup its only when I place a block thats why ive never seen it before

lost matrix
minor garnet
#

a doubt, defining a variable a position of the player's camera with a defined pitch and yaw and defining another variable with a different position, can I define a vector between these two points and get the maximum of the vector reached?

mystic lion
#

Should I keep a mysql connection open if I will constantly be writing and reading when a player joins/leaves and for an interval too?

unreal quartz
#

use a connection pool, like hikaricp

mystic lion
#

No idea how to do that : P

#

@reef granite typing

#

lmfao

reef granite
#

yeah

#

Hey! I have a question.
I'm trying to find the Velocity required to launch the player to an exact location that I know. to do this I needed to do calculations for projectile motion. I did so and it didn't work, so I researched a bit and found out that there's a 2% drag added to the player's velocity (I think) so I calculated the equations using the last way and then added 2% of the velocity back to the velocity (that might have been a wrong thing to do so that's why I need help) but I still can't get it to work.
If anyone knows how to do this, I'd be happy to hear it.

unreal quartz
#

you might find it tricky applying a velocity directly to a player, as they will be subject to stuff like anti-cheats and the client themselves moving, you might want to consider having them riding another entity (like an arrow or something) to simplify your calculations and prevent movement

reef granite
#

I'll check it out, thanks!

scenic valve
#

Quick question: is there any way to disable mobs like skeletons from climbing up ladders in 1.16, just curious

mystic lion
unreal quartz
#

looks fine to me

mystic lion
#

awesome

distant fern
#

I was asking it but i will do it againd because i dont uderstand D:

Defining the constructor in your listener
public MyListener(JavaPlugin plugin)
and then when you instantiate a new listener in the main class extending JavaPlugin
new MyListener(this)

unreal quartz
#

which bit don't you understand

distant fern
#

What am i suuposed to write in main and wchich in Listener

#

I tried bot combination and none woreked

unreal quartz
#

do you know what a constructor is?

distant fern
#

Not really

mystic lion
#

He probably copied it from a tutorial

unreal quartz
#

it is called when instantiating a new class, which is what you do when you use the new keyword

mystic lion
unreal quartz
#

it looks like this (what you wrote)
public MyListener(JavaPlugin plugin) {}, basically a method with no return type

#

so in this case the constructor would go in the listener class (again, what you wrote), and it accepts an instance of your main class as an argument

distant fern
#

Co i wrote my Listener

#

public class ZbozeListener(JavaPlugin plugin) implements Listener {

@EventHandler
public void onBreak(final BlockBreakEvent event) {
    final Block block = event.getBlock();
    if (block.getType() != Material.WHEAT) {
        return;
    }
    final Ageable ageable = (Ageable) block.getBlockData();
    if (ageable.getAge() != ageable.getMaximumAge()) {
        return;
    }
    Bukkit.getScheduler().runTask(this.pluginInstance , () -> block.setType(Material.WHEAT));

}

}

mystic lion
#

i want death

distant fern
#

But still pluginInstance

#

Doesnt work

unreal quartz
#

yes that wont even compile

distant fern
#

Yes

#

But still dont know what to change

#

Sorry im retarded

#

XD

unreal quartz
#
public class ClassName implements Listener {
    public ClassName(JavaPlugin plugin) {
        // do something with plugin
    }
    // ...
}```
this is an example of a constructor, to instantiate a class of this type you would need to do `new ClassName(/* instance of JavaPlugin */)`, I would suggest you learn a bit of basic java before jumping into spigot
distant fern
#

so eventhandler shoul be in wchic bracket

mystic lion
#

@distant fern You did something that I would never expect anyone to do, but you put the.... I don't know what to call it... when you defined the class... remove "(JavaPlugin plugin)" and inside of your actual class I want you to put this:

private YourMainClass plugin;

public ZbozeListener(YourMainClass plugin) {
    this.plugin = plugin;
}```
lost matrix
mystic lion
#

but please learn java

lost matrix
#

^

mystic lion
#

7smile7 I don't think he would understand that

#

lmfao

distant fern
#

sorry

#

Like i tried

#

But ther is no a good tutriotals in my LANGUAGE

mystic lion
#

nooo don't appologise ๐Ÿ˜›

#

everyone starts somewhere

#

what language are you?

distant fern
#

Polish

#

I just write baisc plugins

#

I still cant handle this problem xD

quaint mantle
#

what does synchronized (plugin) do

lost matrix
hollow crow
#

what event would i use to detect only when the players block changes, then get the block theyre walking over?

quaint mantle
#

PlayerMoveEvent

lost matrix
quaint mantle
#

they mean when the player moves blocks

#

like walking over blocks

supple elk
#

Hey guys, anyone got a link to a tutorial/forum post on making custom sounds w/ a resource pack?

lost matrix
#

Oh. Yeah. Then PlayerMoveEvent

hollow crow
#

this is what i have rn, but all it does is tp the player down whenever they look or move:

    @EventHandler
    public void playerMoveEvent(PlayerMoveEvent event) {
        Player p = event.getPlayer();
        Location loc = event.getTo();
        Location loc2 = loc;
        loc2.subtract(0,1,0);
        Block block = loc2.getBlock();
        BlockData data = block.getBlockData();
        Material newBlock = data.getMaterial();
        p.getInventory().addItem(new ItemStack(newBlock));

    }
}```
lost matrix
# quiet ice Implicit?

Yes. You dont have an actual Lock object that can be acquired. (unless you synchronize on a lock)

quiet ice
#

Ah

supple elk
lost matrix
#

You synchronize on a specific Object but the Object is not the lock.

hollow crow
#

how would i make only when they move blocks

#

and not when they look around

quiet ice
#

I get what you mean

quaint mantle
#

so is it good to use synchronized for database management? ๐Ÿค”

supple elk
#

there might be an option in the event, lemme just have a look

quiet ice
#

yes, to avoid race conditions

#

Though choosing the right data types is more important for that

supple elk
hollow crow
#

ok

supple elk
#

the event has .getTo() and .getFrom()

hollow crow
#

thats what i thought i would do

#

and then how would i get the block theyre working on?

supple elk
#

from is the position they were in, to is the position they're going to

lost matrix
# hollow crow how would i make only when they move blocks

Something like this should work.

  @EventHandler
  public void onMove(final PlayerMoveEvent event) {
    final Location from = event.getFrom();
    final Location to = event.getTo();
    if (to == null) {
      return;
    }

    final int fromX = from.getBlockX();
    final int fromY = from.getBlockY();
    final int fromZ = from.getBlockZ();

    final int toX = from.getBlockX();
    final int toY = from.getBlockY();
    final int toZ = from.getBlockZ();

    if (fromX == toX && fromY == toY && fromZ == toZ) {
      return;
    }

    System.out.println("Player walked from [" + fromX + "|" + fromY + "|" + fromZ + "] to [" + toX + "|" + toY + "|" + toZ + "]");

  }
dusty herald
#

getTo could be null? thonk

hollow crow
#

lemme try that

quaint mantle
#

How can I make an ItemSteck that gets a certain players head?

supple elk
#

so just get the location below the player by subtracting one from the y axis

#

then call getBlock()

hollow crow
#

would getBlock get the block they walked on or the on their feet is in

#

oh ok

supple elk
#

the one their feet is in I'd assume

carmine ivy
#

I have a simple question:
How would I send players to different worlds?

#

Am noob

dusty herald
#

Player#teleport

supple elk
#

you can use Location.setWorld()

carmine ivy
#

Ohhh

#

Ok

supple elk
#

pass in the world u want to teleport them to

gritty urchin
#

Hello, how would I read from a text file in my src folder?

supple elk
#

then teleport them to that location

carmine ivy
#

Okay thanks for the help

#

This server is way more active then others lmao

dusty herald
#

no it isn't

dusty herald
#

this is dead

supple elk
#

???

dusty herald
#

we're all dead here

paper viper
#

^

lost matrix
paper viper
#

we're all dead helpers

supple elk
paper viper
#

im about to reach the end of my life like a star

#

bout to go boom boom

eternal oxide
#

We are all recordings repeating the same messages over and over.

dusty herald
#

what's your git pulse

quaint mantle
#

How can I make an ItemSteck that gets a certain players head?

dusty herald
#

DogKek why do you have an among backdoor Pulse

#

for shame

lost matrix
#

I almost thought about making macros for classics like "Pleas take your time and learn Java" and Just sending the how to create a Spigot plugin in <some IDE>

paper viper
dusty herald
#

i found it

paper viper
#

Oh

#

lol

dusty herald
#

nice backdoor btw

#

will def use /s DogKek

paper viper
#

lmfao

#

that was for testing

#

it has a jumpscare in it

#

lol

dusty herald
#

yes i know

#

it also kills all mc instances

paper viper
#

And it has a keylogger

#

๐Ÿคก

eternal oxide
#

I wrote an IRC bot once to recognise frequently asked questions and give canned responses

gritty urchin
dusty herald
#

totally isn't a virus or anything

paper viper
#

Nah never

dusty herald
#

oh jesus

#

crypto too?

paper viper
#

I mean like sending profile json files, kelogging account information input. Nah

#

totally not sus

lost matrix
dusty herald
#

PFF

paper viper
#

lol

dusty herald
#

yeah i see that

supple elk
#

When the programme is sus ahahha hahha hahh a

dusty herald
#

I mean this isn't sus at all

quaint mantle
paper viper
#

Yep not at all

#

Completely legal

#

lol

#

xD

dusty herald
#

yes it is legal

#

only idiots would run it

paper viper
#

so true

dusty herald
#

natural selection at this point

paper viper
#

lol

#

survival of the fittest

dusty herald
#

can u

#

not use all cap

quaint mantle
#

Jesus Christ

dusty herald
#

that isn't a cracked plugin

paper viper
#

Yeah lol

quaint mantle
#

seriously fuck automod

paper viper
#

That is just a backdoor testing thing

#

standalone app

quaint mantle
dusty herald
#

most contain one

paper viper
#

the jumpscares play randomly every 2 hours

lost matrix
paper viper
#

LMAO

dusty herald
#

MY EARS

paper viper
#

XD

dusty herald
#

does it work

paper viper
#

The jumpscare works, yes

hollow crow
#

7smile7 sadly, it did not work

paper viper
#

its targeting windows users as well

#

the jumpscare doesnt allow you to alt f4

dusty herald
#

casually reports repo as malicious

paper viper
#

or delete it

#

lol

quaint mantle
#

How do I build a plugin directly into a folder?

dusty herald
#

idk im not a developer

#
<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>
</plugin>```
#

something like that

paper viper
#

yea

#

we arent developers

dusty herald
#

yeah who's a developer lmao

paper viper
#

we are people who push buttons

#

not developers

quaint mantle
#

M O N K E O N A K E Y B O A R D

dusty herald
#

ill do it

paper viper
#

๐Ÿฅฒ

quaint mantle
#

Oh no

hollow crow
#

@lost matrix sadly, your way did not work

dusty herald
#

didnt work

mystic lion
lost matrix
dusty herald
hollow crow
#

i dont mind if the intended effect also happens when the player looks around, i would just prefer if it didnt

paper viper
#

lol

dusty herald
#

no

#

the rm command

tiny mountain
#

Hey there, im trying to make a cage of iron fence around a player, but idk what would be the cleanest way to do it ...
this is how i get playerpos (sorry im a beginner) :

Location playerpos = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ());
dusty herald
#

you could just

#

player.getLocation()

paper viper
#

uhm

#

lol

lost matrix
dusty herald
#

im gonna play some WD legion for a bit

tiny mountain
#

@dusty herald thanks

dusty herald
#

DogKek np

hollow crow
#

ok i just messed up idea lmao

lost matrix
tiny mountain
#

How do i set blocks around the player now ๐Ÿค”

hollow crow
#

its deleting characters in front of it when i type now

tiny mountain
#

i will use this code on a blockbreak event

lost matrix
tiny mountain
#

Alright ty sir, i will look for that

lost matrix
hollow crow
#

wdym over delete?

quaint mantle
#

on keyboard

#

theres an insert (ins) key

hollow crow
#

oh i read that bad

#

lmao

#

i saw enter

quaint mantle
#

xd

lost matrix
#

The key over your "del" key. Its probably different in every language. Mine says "entf"

quaint mantle
#

idk didn't work with hitachi

#

but it looks good

lost matrix
# mystic lion anyone

Nested snychronized blocks... and synchronizing on a non encapsulated field together with the fact that Hikari is thread safe...
This does not look good

hollow crow
#

ok im definitely making progress, but it gets the block in the players feet

mystic lion
#

oh shit it is nested..

#

sorry didn't realise..

quaint mantle
#

btw can somebody help me with custom plugin messages from bungeecord to spigot like idk how it works and some wikis or smth are just bungeecord things like connect or something

lost matrix
mystic lion
#

So I should just remove synchronized

#

thats it?

distant fern
#

Is there simpe way to replace reesed seeds when wheat is broken?

lost matrix
mystic lion
#

Alright

#

didn't know

lost matrix
distant fern
#

I guess so i but i dont udferstand it and i doesnt work D:

mystic lion
#

Other than that its good?

lost matrix
mystic lion
#

Alright

latent talon
#

hey 7smile

#

any idea how to fix the placeholder thingy

lost matrix
# mystic lion Alright

But you should prefer this approach:

        HikariConfig config = new HikariConfig();

        config.setJdbcUrl( "jdbc_url" );
        config.setUsername( "database_username" );
        config.setPassword( "database_password" );
        config.addDataSourceProperty( "cachePrepStmts" , "true" );
        config.addDataSourceProperty( "prepStmtCacheSize" , "250" );
        config.addDataSourceProperty( "prepStmtCacheSqlLimit" , "2048" );
        
        dataSource = new HikariDataSource( config );
mystic lion
#

oo

#

I like that

lost matrix
latent talon
#

oh we spoke earlier

#

hold on

quaint mantle
#

btw can somebody help me with custom plugin messages from bungeecord to spigot like idk how it works and some wikis or smth are just bungeecord things like connect or something

lost matrix
humble stirrup
#

is there a way to add a build plugin configuration entry to a maven subproject from the command line?

lost matrix
latent talon
#

in a runnable, its being called every 10 ticks

#

but it doesnt even register the placeholder correctly

#

which is the issue

mystic lion
#

            config.setJdbcUrl( "jdbc:mysql://" + host + ":" + port + "/" + database );
            config.setUsername( username );
            config.setPassword( password );
            config.addDataSourceProperty( "cachePrepStmts" , "true" );
            config.addDataSourceProperty( "prepStmtCacheSize" , "250" );
            config.addDataSourceProperty( "prepStmtCacheSqlLimit" , "2048" );

            hikari = new HikariDataSource( config );```
#

so that @lost matrix ?

quaint mantle
#

do you call the method bungeeCount()?

mystic lion
#

And does hikari automatically pool the connections?

latent talon
#

Yes

lost matrix
latent talon
#

10 ticks

quaint mantle
#

show the method

#

where you use it

lost matrix
# latent talon 10 ticks

And does that happen in independent loops?
With this amount of code you narrowed it down to like half a million possibilities.

round finch
latent talon
#

ill send the full code

quaint mantle
#

okay

tiny mountain
#

@round finch well its juste a 3 block high and 1 air block on the player loc

lost matrix
tiny mountain
#
Location playerpos = player.getLocation();
Block test = test.getRelative(playerpos.getBlockX() + 1, playerpos.getBlockY(), playerpos.getBlockZ());
test.setType(Material.IRON_FENCE);
#

idk if thats good

latent talon
#

as i said, the issue is the placeholders not registering

mystic lion
#

What does that statement cache even do?

hollow crow
#

ok final question: how would i add the nbt data of the block to the inventory?

quaint mantle
#

do you have the bungeecord installed in papi plugin like /papi ecloud download bungee

latent talon
#

Yes

quaint mantle
#

okay

mystic lion
#

is that featherboard?

lost matrix
hollow crow
#

so like if the player walks over a chest it would keep the contents

mystic lion
#

If so try: {placeholderapi_bungee_count}

latent talon
#

It's not featherboard

mystic lion
#

ah

#

What is it?

latent talon
#

custom code?

mystic lion
#

right

quaint mantle
#

okay show the full code of the scorebaord showing up

latent talon
#

ok

carmine ivy
#

Per world plugin doesn't work for me on 1.8.3? Anyone know an alternative?

#

Or a fix

mystic lion
lost matrix
latent talon
#

I know

#

I don't know if its registered

#

i meant it doesnt show

carmine ivy
quaint mantle
#

@latent talon sell the full code if possible pls

latent talon
#

yeah hold on

quaint mantle
#

that would be easier

lost matrix
mystic lion
#

woahhhhh

tiny mountain
mystic lion
#

lmfao

lost matrix
heavy mason
hollow crow
carmine ivy
#

Although if there was I would be using it rn

tiny mountain
carmine ivy
lost matrix
#

Its even native to 1.16

latent talon
carmine ivy
#

I wish I found out earlier

opal juniper
carmine ivy
#

POGGG

#

Thanks man

quaint mantle
#

@latent talon try debugging the bungeeCount method like (Bukkit.broadcastMessage(bungeeCount());

latent talon
#

okay

#

hold o

quaint mantle
#

okay

round finch
tiny mountain
#

no top and bottom sir

round finch
#

ok

lost matrix
# latent talon https://pastebin.com/zmMeqcMc

First of all. No:

        } catch (Exception ex) {
            ex.printStackTrace();
        }

Then: Absolutely no! :

    private static Player player;

Last: You improperly used the placeholders:
Its "%bungee_SMP%" not "%bungee_<SMP>%"

#

And be aware that your header/footer will only work for one single player and nobody else

latent talon
#

whats wrong with the ex.printstacktrace()?

mystic lion
#

The thing wrong with that is the "Exception" but I'm going to assume

lost matrix
mystic lion
#

yep

latent talon
#

oh?

latent talon
quaint mantle
#

you should even change the String practicecount = "%bungee_<Practice>%"; to String practicecount = "%bungee_Practice%";

latent talon
#

yeah alright i got that

lost matrix
# latent talon oh?

And you didnt cache your reflections. So on a server with a lot of people, running something like this every 10 ticks without distribution will lead to micro lags.

latent talon
#

but %bungee_total% doesn't work either

quaint mantle
#

Practice is name of server

sick ravine
latent talon
latent talon
sick ravine
#

:C

quaint mantle
#

did the debug showed something?

latent talon
#

didn't run it yet hold on

quaint mantle
#

okay

distant fern
#

Its not supposed to work?

    @EventHandler
    public void onBreak ( final BlockBreakEvent event){
        final Block block = event.getBlock();
        if (block.getType() != Material.WHEAT) {
            return;
        }
        final Ageable ageable = (Ageable) block.getBlockData();
        if (ageable.getAge() == ageable.getMaximumAge()) {
            block.setType(Material.WHEAT_SEEDS);
        }
    }
}
abstract relic
#

u register ur listener?

deft sedge
#

Does anyone know how to change a string into a location?

quaint mantle
#

like a world

#

how does the string look

distant fern
# abstract relic u register ur listener?

Listener:

public class ZbozeListener implements Listener {

    @EventHandler
    public void onBreak ( final BlockBreakEvent event){
        final Block block = event.getBlock();
        if (block.getType() != Material.WHEAT) {
            return;
        }
        final Ageable ageable = (Ageable) block.getBlockData();
        if (ageable.getAge() == ageable.getMaximumAge()) {
            block.setType(Material.WHEAT_SEEDS);
        }
    }
}

Main:

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

deft sedge
#

well my code takes the player location and prints it to a book

distant fern
#

so yes

deft sedge
#

i want to use that location from the book and teleport the player there

quaint mantle
#

you can use something like player.getLocation().getWorld().toString();

#

oh if is there

#

you use Bukkit.getWorld(get playerworld)

abstract relic
#

any error messages?

deft sedge
#

no it stores it to the book as a string beacause I think that's the only way to put it in a book

quaint mantle
#

yeah it does

distant fern
deft sedge
#

no but it is just telling me that i can't use a string as a location

quaint mantle
#

what are u trying to take from the book

abstract relic
#

oh

#

I think WHEAT

quaint mantle
#

a world, x, y ,z or

abstract relic
#

is the item

#

and not the crop block type

deft sedge
#

ok the player types a command and it takes their current location and puts it in the book using player.getlocation then I want them to be able to type a different command,the plugin reads taht book and teleports them to their previous location that is already listed in the book

#

but I think I can only put a string in a book

quaint mantle
#

okay show me the saving method in the book

deft sedge
#

ok one sec

quaint mantle
#

okay

deft sedge
#

Srry for wait

quaint mantle
#

its okay

deft sedge
#

My computer crashed I have to restart

quaint mantle
#

okay take your time

south onyx
#

can someone pls vc with me i rly need help, and what i need would be hard to explain in txt

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.

quaint mantle
south onyx
#

ok sure thats fine

lost matrix
deft sedge
#

Im rebooted im screenshotting code

quaint mantle
#

okay

south onyx
#

for some reason my smithing table event is acting very weird

#

like i add enchants and i test it and it works

#

but like when i add another if statement after that

#

the old if statement stops working

eternal oxide
#

?paste your code

queen dragonBOT
deft sedge
eternal oxide
#

Someone else will help, I don;t do screenshots.

quaint mantle
#

i am helping him

#

@deft sedge wanna go dm?

eternal oxide
#

cool

deft sedge
#

sure

carmine ivy
#

I really don't know whats going on:
Using per world plugin and when I try to reload the plugin using /pwp reload it resets the config file
If there is a way to fix please help!

leaden falcon
#
const promptMessage = player => events.once('PlayerChatEvent', event => event.getPlayer() === player).then(i => i.getMessage());

commands.create('prompt', async sender => {
  sender.sendMessage('Tell me hello.');
  const msg = await promptMessage(sender);
  switch (msg) {
    case 'hello':
      sender.sendMessage('Wow, that is so kind of you :D');
      break;
    default:
      sender.sendMessage(':(');
  }
});

Any thoughts on promptMessage?

#

Should I improve it?

south onyx
leaden falcon
#

I think it's useful and good practice

#

But idk

south onyx
#

for some reason when i put the axe and blaze powder, the axe in the second slot becomes enchanted

leaden falcon
south onyx
#

i only want the result to be enchanted

leaden falcon
#

switch (msg.toLowerCase())

dusty herald
#

msg.toLowerCase()

#

I wish switch statements could be case insensitive

leaden falcon
#

Ye

#

I'm glad I'm working with JS since it wouldn't be possible in Java

#

For promptMessage

lost matrix
leaden falcon
#

And as long as you don't try to step in dirty waters, you won't

#

Any normal person won't be doing !!"true" and !!"false" often

#

And won't use == and will use ===

leaden falcon
#

Java has its own bad legacy features too

#

And it's incredibly verbose

#

So I'm very glad to work with JS

ivory sleet
#

Verbosity isnโ€™t necessarily bad

leaden falcon
#

I mean true

#

But I really don't like it

ivory sleet
#

Yeah itโ€™s a subjective topic indeed

leaden falcon
#

In general, preference is

#

And my preference is JS

#

Preference is subjective tho

ivory sleet
#

More ppl seem to dislike verbosity

leaden falcon
#

Ye, I personally don't

#

I like writing simple, small code to do stuff I want to

ivory sleet
#

Iโ€™m fine with that, we do after all have Langs like js and kotlin and what not

leaden falcon
#

Kotlin actually isn't that bad iirc

#

I just have a preference for JS and TS

ivory sleet
#

Not at all

#

Yeah

leaden falcon
#

The plugin I'm using that I made for JS and TS actually has experimental TS support that I've been working on

#

Doesn't static type check but your IDE should be able to

ivory sleet
#

Interesting

lost matrix
#

I refuse to work on js without the TS layer.
Also one of the weirdest things in js is parsing numbers:

parseInt("Infinity", 10); // -> NaN
parseInt("Infinity", 18); // -> NaN ?
parseInt("Infinity", 19); // -> 18

parseInt("Infinity", 23); // -> 18 ?

Or dependency on ecma version:

parseInt("06"); // always 6
parseInt("08"); // 8 if support ECMAScript 5
parseInt("08"); // 0 if not support ECMAScript 5
south onyx
leaden falcon
#

alr

steep nova
#

?paste

queen dragonBOT
sick ravine
#

Memez

steep nova
#

I need some help. I need to change the block drops for a block every minute. The .equals statement doesn't seem to work when I use an instance variable but it works if I explicitly say Material.STONE, etc.

#

Code for reference ^

dusty herald
#

don't compare enums with .equals()

steep nova
#

It doesn't work with == either

dusty herald
#

debug and see if blockDrop is null

steep nova
#

Should I just make a runner class and check?

#

OK

heavy mason
#

Idk why but I dont like the random number thing

#

Just make a set of Materials

dusty herald
#

also, instead of just running it on repeat, you could just use a local variable and use it inside of the event

eternal oxide
#

Do you get teh message from yoru broadcast saying what type?

steep nova
#

the runnable works fine

#

im checking with debug rn

distant fern
#

Hi. Im just curioous is there a way to make no drop from destroyin item

dusty herald
#
            int choice = new Random().nextInt(6);
            Material blockDrop;
            String blockName;
            switch(choice)
            {
                case 1:
                    blockDrop = Material.STONE;
                    blockName = "Stone";
                    break;
                case 2:
                    blockDrop = Material.GRASS_BLOCK;
                    blockName = "Grass block";
                    break;
                case 3:
                    blockDrop = Material.DIRT;
                    blockName = "Dirt block";
                    break;
                case 4:
                    blockDrop = Material.SAND;
                    blockName = "Sand";
                    break;
                case 5:
                    blockDrop = Material.GRAVEL;
                    blockName = "Gravel";
                    break;
                default:
                    blockDrop = Material.GOLD_ORE;
                    blockName = "Gold Ore";
                    break;
            }
        if(event.getBlock().getType() == blockDrop)
        {
            Block block = event.getBlock();
            block.setType(Material.AIR);
            block.getWorld().dropItemNaturally(block.getLocation(), OPItem.getOPItem());
            event.setCancelled(true);
        }```
#

something like that inside of the event, no pretty tho

steep nova
#

Oh

#

first lemme see what's wrong with my original code

eternal oxide
#

nm,m that won;t work

steep nova
#

Ill implement any improvements you guys suggest after I get this thing to work

eternal oxide
#

Well the only thing I see wrong in that code is using .equals instead of ==

dusty herald
#

what I'm thinking is the Event doesn't know that blockDrop or blockName is set

quaint mantle
#

Hello everyone, does someone here have experience with BouncyCastle lib? More specifically with performing ECDH

dusty herald
#

who knows

eternal oxide
#

or the OPItem is not what you are expcting

steep nova
eternal oxide
#

sysout on it to be certain

dusty herald
#

yeah it is a static method ๐Ÿ‘€

steep nova
#

Because the plugin works as intended if I change blockDrops to something explicit like Material.STONE

steep nova
heavy mason
#

Would using a Set<Material> then picking a random element make any signficant difference?

steep nova
eternal oxide
heavy mason
steep nova
heavy mason
#

Send a paste link of your current code

steep nova
#

I already pasted the relevant parts

wet breach
#

I mean nothing special in how BouncyCastle does it vs say another crypto lib except efficiency

steep nova
eternal oxide
#

an easy test, add a setter for teh blockDrop in the class

quaint mantle
#

@wet breach I'm getting error about point encoding when trying to get Public key from byte array

#
Exception in thread "main" java.lang.IllegalArgumentException: Invalid point encoding 0x30
    at org.bouncycastle.math.ec.ECCurve.decodePoint(Unknown Source)
    at me.inao.ecdhexample.KeyExchange.getPubKeyFromBytes(KeyExchange.java:33)
    at me.inao.ecdhexample.Main.starter(Main.java:18)
    at me.inao.ecdhexample.Main.main(Main.java:10)
heavy mason
#

!bin

#

Whats the command ahhhhh

#

!md5

steep nova
#

?paste

queen dragonBOT
heavy mason
#

._.

#

Ty

quaint mantle
#

Public key is being encoded into Base64 and then sent using Socket to client from server. Client should decode Base64 and use decoded bytes to get PublicKey object

#

btw, it's also possible to use `

#

3 times

#
test
#

As I can see, bytes are correct, so I don't really know what's wrong
Server

[48, 89, 48, 19, 6, 7, 42, -122, 72, -50, 61, 2, 1, 6, 8, 42, -122, 72, -50, 61, 3, 1, 7, 3, 66, 0, 4, -80, -17, 78, -37, 27, 44, -46, -31, 6, -20, -88, 83, -116, 26, 70, -50, 57, 68, -50, 67, 89, 27, 66, -71, 102, 28, 35, -5, 9, -16, 2, -109, -53, 74, 114, -44, -5, -101, 42, -35, -81, -23, 124, 78, -88, 27, 47, -46, -6, 5, 61, 55, 58, -4, 36, -51, 6, -58, 47, -101, -44, -111, 127, 99]

Client

[48, 89, 48, 19, 6, 7, 42, -122, 72, -50, 61, 2, 1, 6, 8, 42, -122, 72, -50, 61, 3, 1, 7, 3, 66, 0, 4, -80, -17, 78, -37, 27, 44, -46, -31, 6, -20, -88, 83, -116, 26, 70, -50, 57, 68, -50, 67, 89, 27, 66, -71, 102, 28, 35, -5, 9, -16, 2, -109, -53, 74, 114, -44, -5, -101, 42, -35, -81, -23, 124, 78, -88, 27, 47, -46, -6, 5, 61, 55, 58, -4, 36, -51, 6, -58, 47, -101, -44, -111, 127, 99]
heavy mason
#

Please

#

?paste

queen dragonBOT
steep nova
heavy mason
#

@quaint mantle

steep nova
heavy mason
#

Did you add the check for a null block?

eternal oxide
#

Well from the code you have shown I see no reason for it to not work.

steep nova
quaint mantle
#

@heavy mason If you mean for the code, I will push server code to GitHub and will send link. For client, code is the same

steep nova
#

should I?

heavy mason
wet breach
#

@quaint mantle Is client and server both something you made?

heavy mason
quaint mantle
wet breach
#

The only thing I could see that could possibly be throwing it off, is that sometimes you have to specify which spec you are using, which there is two names for it.
prime256v1 and secp256r1. The second one is the more accepted name for it, while some are just fine with the former.

quaint mantle
#

Exception is being generated on line 31, decodePoint(raw)

steep nova
#

its raw

quaint mantle
#

yes yes, bake it for 3 hours

wet breach
#
public org.bouncycastle.jce.interfaces.ECPublicKey loadECPublicKeyBC(String encodedPublicKey) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeySpecException, IOException {
    Base64.Decoder base64Decoder = Base64.getUrlDecoder();
    byte[] decodedPublicKey = base64Decoder.decode(encodedPublicKey);
    KeyFactory keyFactory = KeyFactory.getInstance("ECDH", "BC");

    ECParameterSpec ecParameterSpec = ECUtil.getECParameterSpec(openSSLProvider, "prime256v1");
    ECPoint ecPoint = ECUtil.decodePoint(decodedPublicKey, ecParameterSpec.getCurve());

    ECPublicKeySpec pubSpec = new ECPublicKeySpec(ecPoint, ecParameterSpec);
    org.bouncycastle.jce.interfaces.ECPublicKey ecPublicKey = (org.bouncycastle.jce.interfaces.ECPublicKey)keyFactory.generatePublic(pubSpec);

    return ecPublicKey;
}

this is using BouncyCastle

quaint mantle
#

im trying to make a while loop for the player y being 256, i havent done a while true before but this is what ive got and its not working while (player.getLocation().getY() >= "264" (true) {

mystic lion
#

Do I have to close preparedstatements/statements after using them?

#

well not "have to"

#

but should I

wet breach
#

@quaint mantle Did you check that the public key value you have obtained is actually correct?

#

that would be the only other thing I could see going wrong, is that you are generating a key, and then from said key extracting the wrong public key using incorrect values from the private key

quaint mantle
#

@wet breach what pastebin do you use

wet breach
#

?paste

queen dragonBOT
quaint mantle
#

thanks

wet breach
#

the last 6 values of the generated key is what is used to derive the public key if that better helps you @quaint mantle not entirely sure how well versed you are in crypto lol

viscid cave
#

Any one has an example of plugin that uses a websocket?

quaint mantle
#

And since key should be generated correctly (hopefully, it's in init function of KeyExchange.java)

south onyx
#
@EventHandler
    public void onSmith(PrepareSmithingEvent e) {
        if (e.getInventory().getItem(0) != null && e.getInventory().getItem(1) != null) {
            if (e.getInventory().getItem(1).getType().toString().endsWith("_AXE")) {
                ItemStack result = e.getInventory().getItem(1);
                ItemMeta resultMeta = e.getInventory().getItem(1).getItemMeta();
                //List<String> lore;
                if (e.getInventory().getItem(0).getType() == Material.BLAZE_POWDER) {
                    result.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 10);
                }
                if (e.getInventory().getItem(0).getType() == Material.BONE) {
                    result.addUnsafeEnchantment(Main.boneEnchant, 1);
                    resultMeta.setLore(Arrays.asList("Bones"));
                }
                result.setItemMeta(resultMeta);
                e.setResult(result);
            }
        }
    }
#

that is my event

#

but

#

here is what happens:

#

it sets the lore

#

but its not enchanted

wet breach
#

@quaint mantle so the line you linked is for getting the public key from a key. So now the question is, the key being provided, is it a valid ECDH key? And is said key actually being used to encrypt the session or is it just the public key?

twin hazel
#

How do I set a npc selected hotbar slot?

steep nova
#

Okay so I've figured out that blockDrops is null. The thing is, I don't know why

steep nova
#

Ah I pasted it above somewhere

crisp iron
#

hello again,

lost matrix
crisp iron
lost matrix
molten hearth
#

Is there an event prior to PluginEnableEvent?

crisp iron
#

no

molten hearth
#

Bruh

crisp iron
#

i dont think so lol

distant fern
#

I have a question. Why i doesnt work D; Pls help

Main:


import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin implements Listener {


    @Override
    public void onEnable() {

    this.getServer().getPluginManager().registerEvents(new Join(), this);
    }

    @Override
    public void onDisable() {


    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if(label.equalsIgnoreCase("createnpc")) {
            if(!(sender instanceof Player)){
                return true;
            }
            Player player =(Player) sender;
            NPc.createNPC(player);
            player.sendMessage("NPC CREATED");


        }

        return false;
    }
}
lunar wigeon
lost matrix
molten hearth
#

I want to cancel a plugin from loading entirely

distant fern
#

NPc:



public class NPc {

    public 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(), "Farmer");
        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());


    }


    public static void addNPCPackets(EntityPlayer npc){
        for (Player player: Bukkit.getOnlinePlayers()){

            PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
            connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
            connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
            connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) (npc.yaw *256 / 360)));

        }
    }

    public static void addJoinPackets(Player player){
        for (EntityPlayer npc : NPC){

            PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
            connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
            connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
            connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) (npc.yaw *256 / 360)));

        }
    }


    public static List<EntityPlayer> getNPCs() {
        return NPC;
    }


}
steep nova
lost matrix
distant fern
#

Join:


import org.bukkit.entity.NPC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

public class Join implements Listener {

    @EventHandler
    public void onJoin(PlayerJoinEvent event){
        if(NPc.getNPCs() == null)
            return;
        if(NPc.getNPCs().isEmpty())
            return;
        NPc.addJoinPackets(event.getPlayer());

    }


}
quaint mantle
molten hearth
#

Other

dusty herald
#

it's messing with my head

steep nova
#

I accidentally made two objects md_5

dusty herald
#

ASbigBrain its gonna explode

steep nova
#

That's why it was null

crisp iron
#

@7smile7 how does that help? It only returns the world

#

the file for the world

quaint mantle
# molten hearth Other

try this
if (getServer().getPluginManager().getPlugin("PluginName") != null) { getServer().getPluginManager().disablePlugin(getServer().getPluginManager().getPlugin("PluginName")); }
@molten hearth

lost matrix
dusty herald
#

is there an event for when a chunk is being generated for the first time thonk never really put much mind to it

#

I know there's ChunkLoadEvent

distant fern
dusty herald
#

would that be called whenever a player loads a chunk?

dusty herald
#

thanks bb

lost matrix
quaint mantle
#
// Using an API
if (obj == null) return null;
// This IS an API
if (obj == null) throw new NPE
dusty herald
#

wow, such wisdom

lost matrix
crisp iron
#

no, it just never loads the world

#

i wasn't receiving the null pointer at all

#

when i run /worldmng load test it says it loaded, but it never actually does

lost matrix
sharp mason
#

Hi, I wish my plugin could search for players by coordinates, e.g. / examplecommand @a [x = 10, y = 20, z = 20], does anyone have any idea how to do this?

molten hearth
paper viper
#

wait what the fuck

#

change your name

#

lmao

quaint mantle
#

but still, newbie programmers

heavy mason
#

Ironic

rapid vigil
#

Guys I need help with my code:

Location spawn = new Location(Bukkit.getWorld("ffa"), -1074, 80, 96, 175.5, -2.9); Why does it give me error on paw and pitch?

quaint mantle
#

g

paper viper
#

or you can use @Contract

quaint mantle
#

no

paper viper
#

@Contract also works

lost matrix
paper viper
#

you can also define purity with that as well

quaint mantle
heavy mason
rapid vigil
#

I can't send here

paper viper
#

ikr lol

rapid vigil
#

I guess

quaint mantle
#

?paste

queen dragonBOT
quaint mantle
#

send the error

rapid vigil
#

!paste

molten hearth
#

I might be able to use loadBefore and have the same plugin name so that it errors due to a duplicate name entry but I'd rather do it programmatically

rapid vigil
#

How do I upload a picture

molten hearth
#

Wait how am I gonna loadbefore the same plugin name pain

sharp mason
heavy mason
rapid vigil
heavy mason
#

Ez

rapid vigil
fathom timber
#

bro

quaint mantle
#

@rapid vigil you have to change x y z to double and yaw and pitch to float

fathom timber
#

^

molten hearth
#

Or can i dynamically change the plugin name

heavy mason
heavy mason
molten hearth
#

No I'm trying to cause the error so that the 2nd plugin doesn't enable

quaint mantle
#

then do what i told u to do

molten hearth
#

You told me to disable it

quaint mantle
#

or just remove the plugin

heavy mason
#

Yes

#

That works too

quaint mantle
#

xd

molten hearth
#

I can't that's the problem lul

quaint mantle
#

then do what i told u to

rapid vigil
#

Like that?

quaint mantle
#

when its disabled it wont do anything

#

yes @rapid vigil

molten hearth
#

But it messes stuff up within it's onEnable

lost matrix
# sharp mason I'm creating a plugin that will work based on a Yes or No game and I need to det...
  public Optional<Player> getPlayerNear(final Location location, final double range) {
    return location.getWorld().getNearbyEntities(location, range, range, range, entity -> entity instanceof Player)
        .stream()
        .sorted((ent1, ent2) -> (int) (ent1.getLocation().distanceSquared(location) - ent2.getLocation().distanceSquared(location)))
        .map(Player.class::cast)
        .findAny();
  }

Get all players near a location
Sort them by distance from that location
Get nearest player if present

rapid vigil
#

That actually works, No errors but there's 3 warnings

quaint mantle
#

what warnings

rapid vigil
#

Casting '-1074' to 'double' is redundant
Casting '-80' to 'double' is redundant
Casting '-96' to 'double' is redundant

quaint mantle
#

try just changing all the double to int

#

and leave the float as is ig

rapid vigil
#

Changed, but still same warnings

#

now it says:
Casting '-1074' to 'int' is redundant
Casting '-80' to 'int' is redundant
Casting '-96' to 'int' is redundant

quaint mantle
#

show the code like the method

crisp iron
#

i got it to work @7smile7 thanks

young knoll
#

IF you want them as doubles just append a d

quaint mantle
#

oh maybe try ((int) the number)

young knoll
#

For floats, f

rapid vigil
#
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender instanceof Player) {
            Player p = (Player) sender;
            Location spawn = new Location(Bukkit.getWorld("world"), (int) -1074, (int) 80, (int) 96, (float) 175.5, (float) -2.9);
            if(label.equalsIgnoreCase("spawn"))
            p.teleport(spawn);
            p.setHealth(20);
            p.setFoodLevel(20);
            p.getInventory().clear();
            p.removePotionEffect(PotionEffectType.STRENGTH);
        }
    return false;}
}```
fathom timber
#

Does an or ```
|| work in a catch statement? like catch(IOExeception e || MalformedUrlException mue)

#

Would that be possible to attempt something like that?

young knoll
#
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender instanceof Player) {
            Player p = (Player) sender;
            Location spawn = new Location(Bukkit.getWorld("world"), -1074d, 80d, 96d, 175.5f, -2.9f);
            if(label.equalsIgnoreCase("spawn"))
            p.teleport(spawn);
            p.setHealth(20);
            p.setFoodLevel(20);
            p.getInventory().clear();
            p.removePotionEffect(PotionEffectType.STRENGTH);
        }
    return false;}
}```
rapid vigil
#

Thanks a lot!

#

That works!

#

No errors and no warnings

young knoll
fathom timber
#

ah

#

ty

quaint mantle
#

remove the mue

fathom timber
#

oh ye ye

#

im slow

quaint mantle
#

its okay

quaint mantle
#

weird

fathom timber
#

ik the reason

eternal oxide
#

Exception covers ALL exceptions

fathom timber
#

OH

#

DAMN

quaint mantle
#

oh than thats why

young knoll
#

Also don't catch generic exception

#

You shouldn't throw it either

eternal oxide
#

Be specific when adding them

fathom timber
#

aight

#

I was doing a discord webhook

quaint mantle
#

okay

paper viper
#

instead of two

fathom timber
#

no an or statement is 2

paper viper
#

but exceptions

#

you can chain them using |

fathom timber
#

u think?

paper viper
#

?

fathom timber
#

operator*

quaint mantle
#

yeah i think it is too only 2 exceptions

fathom timber
#

ye it is

#

i just checked on stackoverflow

young knoll
#

Ah ye, it is 1

fathom timber
#

How do I disable this?

#

The Y/N prompt

abstract relic
#

u dont

#

just press ctrl + c twice

fathom timber
#

It wasn't like that before smh

abstract relic
#

how are you launching your server?

fathom timber
#

run.bat

abstract relic
#

start script?

fathom timber
#

Ye

abstract relic
#

i mean

#

u could just run a jar manually

fathom timber
#

true

#

I just prefer to do --nogui

abstract relic
#

no i mean

quaint mantle
#

yeah

abstract relic
#

java -jar <options> spigot.jar

quaint mantle
#

but like running a jar doesnt give u an console

abstract relic
#

it does?

quaint mantle
#

never did to me

paper viper
#

it gives you the console if you run it in command prompt. However, --nogui will not let the gui thing pop up

fathom timber
#

^

quaint mantle
#

yeah

abstract relic
#

well yea

quaint mantle
#

@wet breach I've solved it ๐Ÿ˜„ Problem was at sending whole key when I actually don't need it ๐Ÿ˜„

#

just runned the an 1.8.8 spigot jar didnt open anything

abstract relic
#

yea

fathom timber
#

i thought 1.8 was extremely buggy

abstract relic
#

they added console later

fathom timber
#

Ah

abstract relic
#

like i mean

#

the actual gui

lost matrix
# abstract relic it does?

Only if you start it from withing a terminal. stdout does not have to be piped into your terminal.
On linux you can just do java -jar <options> spigot.jar >> some.txt and pipe the console directly into a File.

abstract relic
#

i mean

#

thats what I meant the whole time

#

like manually launching the jar

#

is through terminal imo

#

ive always done it like that I guess but new spigot is cooler I guess

sage swift
#

but 1.8 is best!

#

wtfff

abstract relic
#

you are smoking crack

quaint mantle
#

yea

#

mana.containsKey(player)

paper viper
#

Couple things. The <String,Integer> part at the end isn't necessary and you should be using Map<String, Integer> mana = new HashMap<>(); instead because it allows your code to be more flexible

quaint mantle
#

yes it does

sage swift
#

storing players as strings very good

wet breach
#

@quaint mantle see I knew it had to be something with the key lol

#

glad you resolved it though

paper viper
#

and store players using UUID

#

not String

quaint mantle
#

@wet breach I had to do this: ((ECPublicKey)session.getKeyExchange().getPair().getPublic()).getQ().getEncoded(true));
Instead of: (session.getKeyExchange().getPair().getPublic().getEncoded());

#

๐Ÿ˜„

wet breach
#

Ah that makes sense

paper viper
#

just do Map#get()?

abstract relic
#

it's better practice to define a map like this: ```java
public Map<String, Integer> mana = new HashMap<>();

paper viper
#

and check the value

abstract relic
#

Ideally you wouldnt even make it public

paper viper
#

i said that above ๐Ÿฅฒ

abstract relic
#

OH

#

IM SORRY

paper viper
#

nah all g

#

no

#

mana.get(player.getUniqueId()); to get the value right

#

then compare than to 100

wet breach
round finch
#

?paste

queen dragonBOT
paper viper
#

๐Ÿง

#

no it wouldn't

#

that doesn't make sense lol

abstract relic
#

you're trying to use a uuid object as key in a map that requires a string

sage swift
#

then do Bukkit.shutdown()

abstract relic
#

ooh ok

#

i mean that could work yea

#

i'd probably go with mana.getDefault(player.getUUID(), 0) + 5 as value