#help-development

1 messages Β· Page 2149 of 1

brave trellis
#
    public void executeCommand(World w, String s, Entity e) {
        Location loc;
        ArmorStand stand;
        Location entityLoc = e.getLocation();
        loc = new Location(w, entityLoc.getX(), entityLoc.getY() - 300, entityLoc.getZ());
        stand = (ArmorStand) w.spawnEntity(loc, EntityType.ARMOR_STAND);
        stand.setVisible(false);
        stand.setGravity(false);
        Bukkit.getServer().dispatchCommand(stand, s);
        Bukkit.broadcastMessage("Test");
        stand.remove();
    }
#

s being the command

knotty gale
#

for some reason, when i took a bunch of projects and then put them together (made sure that they had no errors, and I just copied and pasted the code) only the main class worked. any ideas why?

crisp steeple
silver reef
#

hello there,
im a bit new to calling events, but I was wondering what the reason could be that I cant call an event in a loop like this:

        Bukkit.getServer().broadcastMessage("Linkcount: " + links.size());
        if (e.GetRedstoneDevice().HasLinks())
            for (int i = 0; i < links.size(); i++) {
                Bukkit.getServer().broadcastMessage("Trigger!");
                Bukkit.getServer().getPluginManager().callEvent(new BreakEvent(links.get(i), e.GetPlayer()));
            }
        Bukkit.getServer().broadcastMessage("Done!");

My links List has 2 items. Now I want to iterate over both (or all) of them. However no matter how many items I got in my list. All my code stops after calling for the first event. Not sure how to bypass this or why this happens. Spigot 1.18.2

Output of thise code:

Linkcount: 2
Trigger!
Done!
crisp steeple
lost matrix
brave trellis
silver reef
lost matrix
silver reef
#

nope indeed, doesnt work

crisp steeple
#

are you getting any exceptions in console?

lost matrix
#

Do an enhanced for loop

brave trellis
crisp steeple
#

idk why it would work in one of your classes but not the other then

crisp steeple
lost matrix
#
for(Link link : links) {
  Bukkit.getServer().broadcastMessage("Trigger!");
  Bukkit.getServer().getPluginManager().callEvent(new BreakEvent(link, e.GetPlayer()));
}
valid totem
#

so i have an event listener that listens for InventoryOpenEvent, when it equals the player's ender chest i cancel the event and open my own custom ender chest GUI

mighty bane
#

Question, so we were messing around with attriubte modifiers and know we have no idea how to remove it.
This is how we set the attribute:

valid totem
#

problem is, when i close the ender chest, the ender chest block is still open

#

how do i cleanly close the ender chest

crisp steeple
brave trellis
#

trying different things

valid totem
lost matrix
brave trellis
#

to see if my solution was fixed and later fix up the optimization

crisp steeple
mighty bane
crisp steeple
#

(btw you could just open the enderchest animation with packets)

lost matrix
mighty bane
valid totem
#
@EventHandler
    public void enderChestOpenListener(InventoryOpenEvent event) {
        if (event.getInventory().equals(event.getPlayer().getEnderChest())) {
            if (ExtendedEnderChest.openedEnderChest.contains(event.getPlayer().getUniqueId())) return;
            event.setCancelled(true);
            ExtendedEnderChest.openedEnderChest.add(event.getPlayer().getUniqueId());
            Bukkit.getScheduler().runTaskLater(Main.instance, new Runnable() {
                public void run() {
                    ExtendedEnderChest gui = new ExtendedEnderChest();
                    gui.openInventory((Player) event.getPlayer());
                }
            }, 1L);
        }
    }
    
#

ender chest block opens fine and the gui appears

crisp steeple
valid totem
#

yeah, the ender chest opens

#

then it immediately closes

#

lol

crisp steeple
#

oh

silver reef
valid totem
#

right now i have this

crisp steeple
valid totem
#

yeah

#

right now my solution was to use reflection to get the net.minecraft.world.level.block.entity.TileEntityEnderChest

#

then call the stopOpen method

#

which reduces the open counter

#

and sends a packet to the client to close the chest

#

and the chest immediately reopens

crisp steeple
#

a packet to close the chest?

#

bad idea

valid totem
#

no NMS does that for me

valid totem
#

i just tell NMS that the player closed the chest

crisp steeple
silver reef
# lost matrix Show the whole code please

the event being called is doing only this:

        for (int i = 0; i < links.size(); i++){
            if(links.get(i).getId().equalsIgnoreCase(id)){
                links.remove(links.get(i));
                return;
            }
        }
valid totem
#

and i already tried it

crisp steeple
#

hm

valid totem
#

what if i tell craftbukkit that the chest closed instead of NMS

crisp steeple
#

?

#

wdym

valid totem
#

i call some method on CraftEnderChest

crisp steeple
#

you dont just wanna instantly close the inventory

lost matrix
valid totem
#

no the inventory stays open

#

but when i close the inventory the chest doesnt close

silver reef
valid totem
#

i can see it start to close for a split second

#

but it reopens

crisp steeple
valid totem
#

custom one

silver reef
#

@lost matrix ill have to dm you to avoid spam

vocal cloud
#

Or make a thread?

silver reef
#

sure if u want to

undone axleBOT
valid totem
#

right now im just grepping craftbukkit codee

#

heyyy this looks very promising

#

wait it literally calls the same method

#

:q

silver reef
#

all my classes that have to do something with this in order

lost matrix
#
  1. You should use a Map<String, Link> inside RedstoneDevice
#
  1. You should not store the players id as a String. Just keep it a UUID...
silver reef
#

alr thnx ill see if it fixes

knotty gale
#

is there something wrong with this?

commands:
  ArrowLogs:
  ArrowShot:
  Flag:
  w:
  w2:
  fumble:
  h:
  pc:
```?
crisp steeple
#

yes

knotty gale
#

what is it?

crisp steeple
#

you are just creating a key of something with no value

knotty gale
#

this is a plugin.yml

crisp steeple
#

okay

#

you are sitll just creating a key of something with no value

lost matrix
# silver reef alr thnx ill see if it fixes

You should never have getters for any collections. No getters for lists, sets, maps etc.
Make .GetLinks() return a copy of your original data. This will fix the ConcurrentModificationException

knotty gale
#

so how should I do multiple commands?

crisp steeple
#

the same way you would do one command?

#

but just repeat it

knotty gale
#

thats what I did

#

usage and description are optional

crisp steeple
#

so what is the problem you are having then

knotty gale
#

that only the first command works

crisp steeple
#

are you registering them?

silver reef
#

altough running it again seems to not help

knotty gale
crisp steeple
#

thats not how you properly register comands

#

idk why so many people do that

knotty gale
#

cause that was how i was taught

crisp steeple
#

it might work but it is also incredibly messy and buggy

#

make a command executor for every command

knotty gale
#

well it works for the commands i use when i put the commands in different classes

#

actually I figured out the problem

#

only my main class works

#

how do I fix that?

#

like any ideas whats wrong

crisp steeple
#

what?

#

what is your code in other classes

knotty gale
#

A bunch of listeners

crisp steeple
#

listeners for?

silver reef
#

@lost matrix the code works and iterates through the list properly calling the event multiple times when I remove the code in the Break() function:

    public void BreakLink(String id){
        //for (Link link : GetLinks())
        //    if(link.getId().equalsIgnoreCase(id)){
        //        links.remove(link);
         //       return;
         //   }
    }
knotty gale
#

people being shot, shooting, placing blocks

#

and some commands

#

like one that starts a count down

crisp steeple
#

ok so can you send the code for the commands

knotty gale
#

yes

crisp steeple
#

im assuming its not working in your other classes since you're using the not correct way of using the javaplugin command registering

#

in which case you would want to use commandexecutors

knotty gale
#

ok

#
public class Whistle extends JavaPlugin {
    
    @Override
    public void onEnable() {
        // startup
        // reloads
        // plugin reloads
    }
    
    @Override
    public void onDisable() {
        //shutdown
        //reloads
        //plugin reloads
    }
    
    // /hello <-- Hey welcome!
    
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (label.equalsIgnoreCase("w")) {
            if (sender instanceof Player) {
                // player
                Player player = (Player) sender;
                if (player.hasPermission("Hello.use")) {
                    Bukkit.broadcastMessage(ChatColor.WHITE + "<" + ChatColor.AQUA + "BlockyRef" + ChatColor.WHITE + "> " + ChatColor.RED + "" + ChatColor.BOLD + "THE REFEREE HAS WHISTLED STOP THE GAME");
                    for (Player players1 : Bukkit.getOnlinePlayers())
                     {
                        players1.playSound(players1.getLocation(), Sound.ENTITY_ARROW_HIT, 1, 1);
                    return true;
                     }
                }
                player.sendMessage(ChatColor.RED + "You do not have permission!");
                return true;
            }
            else {
                // console
                sender.sendMessage("Hey console!");
                return true;
            }
        }
        
        
        
        return false;
    }

}}
#

ik its probably messy

crisp steeple
#

so this is your main class?

valid totem
#

how do i close the chest

knotty gale
crisp steeple
#

why is it extending javaplugin then...

knotty gale
#

you know what good question

#

would you think it would break the plugin?

crisp steeple
#

yes...

knotty gale
#

ok ty

crisp steeple
#

there is only supposed to be one class that extends javaplugin

knotty gale
#

i kinda have no idea what im doing

#

but that is why im here

crisp steeple
knotty gale
crisp steeple
#

yes

knotty gale
#

ok ty

silver reef
#

callEvent in loop

knotty gale
#

would I also register all my listeners in my main class?

knotty gale
#

@crisp steeple so I did what you said and most of the stuff works. But the classes I have where there are commands AND listeners wont work, any fixes?

river oracle
#

when doing this you have to make sure you register not only the command but also the listener

knotty gale
#

ok

subtle folio
#

The Worldgaurd docs are quite bad, does anyone know how to check what region a player is in?

valid totem
#

YES I DID IT

#

fucking nms

worldly ingot
#

Commenting in between method invocations is different. I'd personally do // getEnderChestInventory(), stopOpen() at the end of the line, but I guess it's a matter of preference and readability

valid totem
#

whats the event when someone double clicks an item to get all items of the stack to get picked up by the cursor

#

for ex theres 32 dirt in the chest

#

and 32 in my inventory

#

i double click the 32 in my inventory and now i have all 64

#

this is so cursed

void mason
#

hi

#

is it possible to detect te mouse scrolling when a player spectate an entity ???

wind tulip
valid totem
#

no

wind tulip
#

then there you go

valid totem
#

because i need to allow players to put stuff inside

#

lol

wind tulip
#

well

valid totem
#

"Ender Chest"

wind tulip
#

you could check if the clicked item is air

#

nvm

#

wait

valid totem
#

an ender chest but you cant put items in

wind tulip
#

so unless there's some kind of spigot thing you could do here, there's two options

#

You could rename the glass panes to something specific so that the player won't have the item and therefore cannot double click it, although you're already doing this so I assume you don't want this

valid totem
#

yeah no player has glass panes called " "

#

but on hypixel skyblock someone gave me these "menu glass" and i was farming free glass from the guis

wind tulip
#

you could also make ur own system, where you set the slot item to the cursor item if the clicked item is air, or add to the item's stack size if it's not air

#

might look jank but yk

void mason
#

can someone help me please ?

dusk flicker
#

not without a question

#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

void mason
#

is it possible to detect te mouse scrolling when a player spectate an entity ???

wind tulip
#

make sure you clear their inventory every tick though

#

and also cancel drop item

void mason
#

okay thanks

#

and the player still spectate the target ?

wind tulip
#

here's an example

dusk flicker
#

how would setting a players gamemode to creative let you detect mouse scrolling

wind tulip
dusk flicker
#

oh I see

#

ah

crisp steeple
#

there’s a way to stop double clicking certain items out

wind tulip
#

also you wanna lock the hotbar slot to 5 (cancel change slot event) and check if the event slot is above or below 5 to see if they scrolled down or up

void mason
#

thanks πŸ™‚

crisp steeple
#

there’s a lot of ways you could get around this otherwise

wind tulip
#

Wait, if I install an api as a jar file, can I still import it through pom.xml somehow or should I add it as a module

valid totem
#

the item in the clicked

void mason
#

is there a way to hide the HUD when the gamemode is survival???

#

i mean not with f1

#

i mean force hide the HUD

wind tulip
#

so that the xp bar doesn't show

stone obsidian
#

yoo

#

this sucks, im compiling a plugin with maven in intellij and I know it's usually 2mb but somehow now every time I compile it's 25kb

#

needless to say it doesn't load, but also doesn't give any errors or warnings

#
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>io.github.TurpCoding</groupId>
    <artifactId>EasyReport</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>EasyReport</name>

    <description>Easy and simple way to report players, all additional features are disabled by default.</description>
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <url>TurpCoding.github.io</url>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>```
#
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

    <repositories>
        <repository>
            <id>spigotmc-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.18.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>```
#

here is the pom

#

can someone please help me

river oracle
#

?paste

undone axleBOT
river oracle
#

fuck all if I'm reading that in that format

stone obsidian
#

wtf is that website lol

#

terminal pastebin

round agate
crisp steeple
quaint mantle
#

is that an already made plugin

#

by you i suppose

drowsy helm
#

sheesh that is real cool

shut field
#

I tried to Maven import it but I am still getting the same the error

drowsy helm
#

are you importing spigot or spigot-api

valid totem
#

does opening another inventory over an already opened inventory call inventorycloseevent for that inventory

eternal oxide
#

Yes, but don;t open an inventory from teh InventoryClickEvent

valid totem
#

i open inventories from inventoryclickevent but i use scheduler runtask

#

is that ok

eternal oxide
#

yep, thats teh correct way to do it

dense shoal
#

Hello! Has anyone ever heard anything about being able to apply the worldborder effect to something? https://i.imgur.com/kJi8K6j.png

I have a use case where I'd like to apply this effect to a certain area. I don't want it to be the worldborder, but I'd like to use the graphical effect.

grand perch
#

So you just want the red screen effect?

compact cape
#

If Mojang keeps adding materials, I think some one needs to categorize them 🀷

8 GB of ram is not even enough for Intelij when trying to use Materials πŸ˜‚ It always freeze for several seconds 😦

#

Finally I did it... Any exception my plugin throw, Is now handled by my own plugin!

vocal cloud
#

I've never seen 8 GB of ram being used by intellij with multiple instances of things open and running πŸ‘€

tranquil viper
#

I had a horrible problem with intellij today using horrible amounts of resources

#

What is the most efficient way to check if a random location is within a border spigot

kind hatch
#

Get the size of the world border and check if the value of the random location is less than or equal to the size of the border.

tranquil viper
#

Well that was my initial thought, but the world border is constantly moving so there's no telling where the world could go to which could present an issue.

kind hatch
#

That shouldn't be an issue though. As long as you are grabbing an updated/recent value, then it should be fine.

tranquil viper
#

Well if I'm going to getting locations hundreds if not thousands of times fairly consistently couldn't that start to slow down the server?

#

Because it's impossible to know how many times it will have to retry to find a safe location

#

My other thought was maybe to use the world border and size to create some sort of mathematical function that could get a random location

kind hatch
#

Only if you are actually dealing with locations on that scale.

#

The world border is just a number. So it won't take up that much memory. Locations on the other hand, they take up a little bit more.

#

Are you planning on having thousands of locations checked frequently?

tranquil viper
#

Yes, upwards of 5 minutes straight

tranquil viper
kind hatch
#

Hmm, what are you creating here? Because I'm under the impression its something like a random teleport system that checks for safe locations.

tranquil viper
#

It is, but its for hundreds of entities

kind hatch
#

Not just players?

tranquil viper
#

Not players at all, it would be mobs such as creepers, enderman, pigs, cows, etc.

crisp steeple
kind hatch
#

Interesting. What's the purpose? A gamemode? Simulated mob spawning?

tranquil viper
#

Sort of like entity raining

#

Idk I'm just bored and want to test it out

#

Thought I might be able to learn from it

compact cape
kind hatch
#

Well if you are worried about the performance, it'll come down to how you make your safe location check. It's what will be called the most. If you take what most rtp plugins use for players and modify it to allow entities, then it shouldn't be that bad.

It all depends on your world/map and what you are checking for. If you are just trying to avoid lava, you likely won't have more than 5 tries at the worst per entity. If you need a more thorough check like no lava and the surrounding area around the entity, then it will become more computational heavy.

crisp steeple
#

neat

#

quite useful

compact cape
#

I can see the next generation of plugins using this πŸ˜‚

#

I made a (intentional) NPE (with no try and catch) in the code and instead of a full trace back I have this

crimson terrace
#

Im already using something similar but I still try catch and save it to a log file

#

imagine a while loop which always throws an exception, wouldnt wanna have a file for each one

dark arrow
#

How can i get the display name of the block i am placing so that i can avoid player from placing a specific block?

crimson terrace
#

check the itemstack inside the BlockPlaceEvent?

#

its called itemInHand I believe

dark arrow
#

ok

#

it worked, Thanks

crimson terrace
#

np

echo granite
#

Easy

#

Ofc make that class

small current
#

guys is there a way to listen for a player's inventory update and get the item(s) added to it ?

#

with packets or whatever

#

im trying to make a rarity system

dark arrow
#

i am trying to summon a sqaure wall of custom length but i am getting messed up by loop,is there any way or formula i can use to summon it?

hybrid spoke
#

there is no generic event you could check for

small current
#

of a player

dark arrow
hybrid spoke
hybrid spoke
halcyon hemlock
#

someone help me with mongodb i cant get it to work

#

i connected to the database

dark arrow
# hybrid spoke so show us what you got (code+screens would be useful)

for(float i=0;i<4;i++){
                Block block1 = locationInFront.add(0,i,0).getBlock();
                block1.setType(Material.COBWEB);
                Block block2 = locationInFront.add(1,i,0).getBlock();
                block2.setType(Material.COBWEB);
                Block block3 = locationInFront.add(0,i,1).getBlock();
                block3.setType(Material.COBWEB);


            }```
#

I cant attach image?

compact cape
#

But now you mentioned it... I think I will try to not save duplicated errors.

crimson terrace
halcyon hemlock
#

how do i use database pls tell

chrome beacon
#

u put stuff in it

#

Answered with the same amount of detail as your question

crimson terrace
#

youre not gonna get a full course on databases here so youre gonna have to be specific

hybrid spoke
undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

hybrid spoke
halcyon hemlock
#

i can connect to db

#

but

#

if i try to add / pull collections it doesnt work

hybrid spoke
#

once again

#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

halcyon hemlock
#

ok so

#

i do that

#
                .append("wheels", 4)
                .append("isFast", true);
        col.insertOne(data);
#

i try that

#

and it doesnt work

hybrid spoke
#

all good things are 3 huh

chrome beacon
#

Send all the code in a paste

#

?paste

undone axleBOT
halcyon hemlock
#

it has my database code

#

and my password

hybrid spoke
#

never hardcode that

chrome beacon
#

Why is the password hardcoded ;/

halcyon hemlock
#

wdym

#

then how

hybrid spoke
#

file

#

config

#

whatever

#

but never hardcode a password

halcyon hemlock
#

?

echo basalt
#

Why hardcode a password when you can make it configurable, saving time in case a server node dies or the IP switches

crimson terrace
#

how do you prevent your personal db password from getting into the hands of people who decompile your jar file?

#

been wondering that for a good while now

crimson terrace
#

at one point I had 72k lines of errors in my log file

compact cape
compact cape
crimson terrace
#

well the good thing is that I knew I had to fix something

hybrid spoke
compact cape
hybrid spoke
#

as long as you authenticate it

crimson terrace
#

how would one authenticate it when the plugin runs on a lot of servers

hybrid spoke
#

with a token or whatever

golden kelp
#

hey guys

#

I am getting an error while serializing my YAML file

#

it says it cant find my custom class

lost matrix
#

Stack trace please. Does your custom class implement ConfigurationSerializable?

golden kelp
#

Yes it does

#

give me a second

#

even though I
-Register it
-have a constructor with map<String, Object>
-have a valueOf method
-have a deserialize method

lost matrix
#

One of them is enough. Remove the other ones.

golden kelp
#

.

lost matrix
#

This might indicate that you are trying to load a yml file before the class loader of your plugin is initialized.

golden kelp
#

gimme a sec imma check quickly

lost matrix
#

When are you loading this file?

golden kelp
#

the YAML?

#

when the plugin is loaded

lost matrix
#

So in your onLoad?

golden kelp
#
@Override
    public void onEnable() {
        // Plugin startup logic
        portalsFile = new File(getDataFolder(), "portals.yml");
        if (!portalsFile.exists()) {
            config = new YamlConfiguration();
            List<Portal> portalList = List.of(createDefaultPortal(), createDefaultPortal());
            config.set("portals", portalList);
            try {
                config.save(portalsFile);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        } else {
            config = YamlConfiguration.loadConfiguration(portalsFile);
        }
        ConfigurationSerialization.registerClass(Portal.class, "Portal");
        this.getCommand("vreload").setExecutor(new ReloadConfig(this));
        this.getServer().getPluginManager().registerEvents(new PlayerBlockEnterEvent(this), this);
        loadPortals();
    }
private void loadPortals() {
        config.getMapList("portals")
            .forEach(map -> portals.add(Portal.deserialize((Map<String, Object>) map)));
    }
lost matrix
#

It should be

((List<Portal>)config.getList("portals")).forEach(portal -> portals.add(portal));
golden kelp
#

o

#

wait a second

#

lemme show my yaml

#

as i was confused bout this part

#

the yaml is kinda like this

#
- objectOne:
  .....
- objectTwo:
  .....
lost matrix
#

I know how your yaml file looks like by looking at your default creation

golden kelp
#

ookay

#

IntellIJ thinks the cast is redundant

lost matrix
#

Its a list of objects. In your case: A list of Portal

golden kelp
#

o

lost matrix
golden kelp
#

wdym

#

Oh

#

portals is a list of portals

#

List<Portal>

#

ohhh

#

i never initilize it

lost matrix
#

Then you can either use the bulk operator:

portals.addAll((List<Portal>)config.getList("portals"));

Or directly define it with the deserialized stuff:

portals = (List<Portal>)config.getList("portals");

Whatever you prefer.

golden kelp
#
public final class VClasses extends JavaPlugin {
    private YamlConfiguration config;
    private List<Portal> portals = new ArrayList<>();
    private File portalsFile;
    
    @Override
    public void onEnable() {
        // Plugin startup logic
        portalsFile = new File(getDataFolder(), "portals.yml");
        if (!portalsFile.exists()) {
            config = new YamlConfiguration();
            List<Portal> portalList = List.of(createDefaultPortal(), createDefaultPortal());
            config.set("portals", portalList);
            try {
                config.save(portalsFile);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        } else {
            config = YamlConfiguration.loadConfiguration(portalsFile);
        }
        ConfigurationSerialization.registerClass(Portal.class, "Portal");
        this.getCommand("vreload").setExecutor(new ReloadConfig(this));
        this.getServer().getPluginManager().registerEvents(new PlayerBlockEnterEvent(this), this);
        loadPortals();
    }
    
    public YamlConfiguration getConfig() {
        return config;
    }
    public List<Portal> getPortals() { return portals; }
    public File getPortalsFile() { return portalsFile; }
    private Portal createDefaultPortal() {
        Location start = Bukkit.getWorlds().get(0).getSpawnLocation();
        Location end = Bukkit.getWorlds().get(0).getSpawnLocation();
        List<String> commands = List.of("/spawn %p%", "/help");
        List<ItemStack> items = List.of(new ItemStack(Material.STONE, 32), new ItemStack(Material.COBBLESTONE, 32));
        List<PotionEffect> effects = List.of(new PotionEffect(PotionEffectType.ABSORPTION, 500, 1));
        return new Portal(start, end, commands, items, effects);
    }
    
    private void loadPortals() {
        portals.addAll(((List<Portal>) config.getList("portals")));
    }
}
#

Then you can either use the bulk operator:
portals.addAll((List<Portal>)config.getList("portals"));
Yea i m doing ths thing

lost matrix
#

One bracket pair too many

golden kelp
#

wdym

lost matrix
#

portals.addAll(((List<Portal>) config.getList("portals"))); -> portals.addAll((List<Portal>) config.getList("portals"));

golden kelp
#

oh yea

#

mb ty

undone axleBOT
golden kelp
#

getting this error

#
@Override
    public void onEnable() {
        // Plugin startup logic
        portalsFile = new File(getDataFolder(), "portals.yml");
        if (!portalsFile.exists()) {
            config = new YamlConfiguration();
            List<Portal> portalList = List.of(createDefaultPortal(), createDefaultPortal());
            config.set("portals", portalList);
            try {
                config.save(portalsFile);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        } else {
            config = YamlConfiguration.loadConfiguration(portalsFile);
        }
        ConfigurationSerialization.registerClass(Portal.class, "Portal");
        this.getCommand("vreload").setExecutor(new ReloadConfig(this));
        this.getServer().getPluginManager().registerEvents(new PlayerBlockEnterEvent(this), this);
        loadPortals();
    }
golden turret
#

('io.github.vinesh27.vclasses.entities.Portal')

golden kelp
#

yes

golden turret
#

you need to register this class to the ConfigurationSerialization

#

bruh

golden kelp
#

I did that

golden turret
#

i jsut saw

golden kelp
#
        ConfigurationSerialization.registerClass(Portal.class, "Portal");
#

ohh

golden turret
#

you need to do it BEFORE load the config

golden kelp
#

do i gotta register it before the ifCheck?

#

oh

#

ty

golden turret
#

πŸ‘

#

pov: you just coded a line in the wrong place

sand orchid
#

is there a simple way to track if a player is stationary, for context im making a stamina system and i want the player to regenerate stamina faster when not moving

earnest forum
#

player move event

#

check if the new location is the same as old location

golden turret
#

you can create an object for the player

#

and store the old location

#

and have a runnable that runs each tick

#

and see if the player moved

earnest forum
#

or just use player move event

#

doesnt get ran if the player doesn't move and it still runs every tick

#

also runs if u move camera tho

golden turret
#

thatts the problem

earnest forum
golden turret
#

doesnt ran if the player is stopped

#

he will need a runnable

#

to see if the player is stopped

sand orchid
#

r u guys talking abt the same thing lmfao im so confused

#

uhh

#

so

#

i get a runnable

#

and grab the location x y z of a player

golden turret
#
class MyPlayer {
  Player player;
  boolean stopped;
}```
#

and at the move event, set stopped to false

#

i lost myself

golden kelp
#
//Check if the player is in a portal and get which one is it
    public Portal getPortal(Player player) {
        for (Portal portal : vClasses.getPortals()) {
            BoundingBox box = BoundingBox.of(
                portal.startBlock(),
                portal.endBlock()
            );
            if(box.overlaps(player.getBoundingBox()))
                return portal;
        }
        return null;
    }

This is how I check if a player is inside a specific portal, but even though the player is, it returns null

earnest forum
#

public PlayerMove(PlayerMoveEvent e){

  if (e.getTo().getX() == e.getFrom().getX()){
    //stationary, do this for y and z too
  }
}
golden kelp
sand orchid
golden turret
#

only check x y z

#

not yaw pitch

golden turret
golden kelp
#

location

golden turret
#

like, are they a Location or Vector

golden kelp
#

Location

sand orchid
golden turret
#

you could use Vector

#

and a getter for the world inside the Portal

golden kelp
#

ok will try

#

wdym

#

and a getter for the world inside the Portal

earnest forum
#

make sure to check the y and z variables too

golden turret
#

so you could check for playerVector.isInAABB(start, end)

golden kelp
#

oo

golden turret
#

withou needing to create 2 vectors object

#

you would create only 1 from playerLocation.toVector

#

or

#

wait

#

@golden kelp

#

you can simply grab the code inside isInAABB

golden kelp
#

o nice

golden turret
#

and create a separate method that accepts location

golden kelp
#
//Check if the player is in a portal and get which one is it
    public Portal getPortal(Player player) {
        for (Portal portal : vClasses.getPortals()) {
//            BoundingBox box = BoundingBox.of(
//            );
            boolean x = player.getLocation().toVector().isInAABB(
                    portal.startBlock().toVector(),
                    portal.endBlock().toVector()
            );
            if(x) {
                System.out.println("In the portal B");
                return portal;
            }
        }
        return null;
    }
#

not working

#

says portal is null

golden turret
#
public boolean isInAABB(Location toCheck, Location start, Location end) {
  if (!location.getWorld().equals(start.getWorld())
    return false;
  //grab code from the vector class
}```
golden kelp
#

//grab code from the vector class

#

wydm sorry

golden turret
#

line 391

#

do the same

#

but with Location

#

using the star and end

#

start will be the min

#

end will be the max

#

use getters

golden kelp
#

return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z;

this is some smart af maths i m too dumb to understand xD

earnest forum
#

it just looks complicated

golden turret
#

that is not math

earnest forum
#

really isnt

golden kelp
#

getX returns a doubel though, should I just use getBlockX?

#

nvm

earnest forum
#

yes

golden turret
#

it is just a greater than smaller than check

#

i would use the getX

#

to be more precise

golden kelp
#

aight

#

Stil

#

Still

#

nvm wait a sec

#

Nop, the portal is still null

#
//Check if the player is in a portal and get which one is it
    public Portal getPortal(Player player) {
        for (Portal portal : vClasses.getPortals()) {
            if(isInAABB(player.getLocation(), portal.startBlock(), portal.endBlock())) {
                System.out.println("In the portal B");
                return portal;
            }
        }
        return null;
    }

    public boolean isInAABB(Location toCheck, Location start, Location end) {
        if (!toCheck.getWorld().equals(start.getWorld()))
        return false;
        //grab code from the vector class
        return
                toCheck.getX() >= start.getX()
                && toCheck.getX() <= end.getX()
                && toCheck.getY() >= start.getY()
                && toCheck.getY() <= end.getY()
                && toCheck.getZ() >= start.getZ()
                && toCheck.getZ() <= end.getZ();
    }
#

bump

golden kelp
#

to check if the player went through a specific portal

#

and if he did

#

return that one

hybrid spoke
#

and what is a start and endblock of a portal?

golden kelp
#

two ends

#

far ends

hybrid spoke
#

and this big confusing block of booleans

hybrid spoke
#

so you want to check if the player is standing in a portal, right?

golden kelp
#

yes

#

and get that portal

hybrid spoke
#

and the portals location is probably just a location?

golden kelp
#

wdym

hybrid spoke
#

where the portal is

#

or is it like a huge area

golden kelp
#

yes

#

and i have confirmed the coords in the code are same

#

(i get them from the config)

hybrid spoke
#

either or question : yes

golden kelp
#

oh

#

sorry

#

is it like a huge area
yes

#
public Portal(
        Location startBlock,
        Location endBlock,
        List<String> commands,
        List<ItemStack> items,
        List<PotionEffect> effects
    ) {
        this.startBlock = startBlock;
        this.endBlock = endBlock;
        this.commands = commands;
        this.items = items;
        this.effects = effects;
    }
#

this is a portal

quaint mantle
#

Whoever sent me the article from spigot explaining about databases and how it should be done, may god bless you.

hybrid spoke
golden kelp
#

yes

#

I printed the entry as I iterate it, and it did show the right portal (object, not the ingame portal)

quaint mantle
#

Is it better to use MysqlDataSource, or DriverManager, if so, what is the difference ?

#

If someone can explain?

golden kelp
hybrid spoke
golden kelp
#
//Check if the player is in a portal and get which one is it
    public Portal getPortal(Player player) {
        for (Portal portal : vClasses.getPortals()) {
            player.sendMessage(portal.toString() + "\n");
            if(isInAABB(player.getLocation(), portal.startBlock(), portal.endBlock())) {
                System.out.println("In the portal B");
                return portal;
            }
            if(isInAABB(player.getLocation(), portal.endBlock(), portal.startBlock())) {
                System.out.println("In the portal B");
                return portal;
            }
            return portal;
        }
        return null;
    }
#

here

#
public boolean isInAABB(Location toCheck, Location start, Location end) {
        if (!toCheck.getWorld().equals(start.getWorld()))
            return false;
        return
            toCheck.getX() >= start.getX()
            && toCheck.getX() <= end.getX()
            && toCheck.getY() >= start.getY()
            && toCheck.getY() <= end.getY()
            && toCheck.getZ() >= start.getZ()
            && toCheck.getZ() <= end.getZ();
    }

this is the method

golden kelp
hybrid spoke
#

try to find the min and maxs first

#

instead comparing the "raw" values

golden kelp
#

wdym

hybrid spoke
#

like the Vector class does

golden kelp
#

I dont understand

hybrid spoke
#

toCheck isnt always bigger than start

#

because end could also be lower than start

glossy venture
#

yeah u have to Math.min / Math.max

hybrid spoke
#

so you would need to find the min and maxs of start and end

golden kelp
#

ohhh

golden kelp
hybrid spoke
#

since you always have 2 corners no matter what, you would just have to Math.min and Math.max the values

#

like min(start.x, end.x)

golden kelp
#

ohh okay

hybrid spoke
#

that would give you the lower value of those 2

#

same for max

golden kelp
#

Math.max() will give me the bigger value

#

and then?

hybrid spoke
#

you do that for x, y and z and have your 2 corners

#

then you can do your check if its between

golden kelp
#

nvm it returns an int

#

so I make a location with all the max ints

#

and thats my start?

hybrid spoke
#

no you then just compare the values with your toCheck

#

basically exactly what the Vector class does

golden kelp
#
return
            toCheck.getX() >= Math.max(start.getX(), end.getX()
            && toCheck.getX() <= end.getX()
            && toCheck.getY() >= start.getY()
            && toCheck.getY() <= end.getY()
            && toCheck.getZ() >= start.getZ()
            && toCheck.getZ() <= end.getZ();
#

like the first condition

#

for all?

#
return
            toCheck.getX() >= Math.max(start.getX(), end.getX())
            && toCheck.getX() <= Math.min(start.getX(), end.getX())
            && toCheck.getY() >= Math.max(start.getY(), end.getY())
            && toCheck.getY() <= Math.min(start.getY(), end.getY())
            && toCheck.getZ() >= Math.max(start.getZ(), end.getZ())
            && toCheck.getZ() <= Math.min(start.getZ(), end.getZ());
hybrid spoke
#

wrong order

golden kelp
#

min is max and max is min?

hybrid spoke
#

basically exactly what the Vector class does

golden kelp
#

oh

#

ty

#
public boolean isInAABB(Location toCheck, Location start, Location end) {
        if (!toCheck.getWorld().equals(start.getWorld()))
            return false;
        return
            toCheck.getX() >= Math.min(start.getX(), end.getX())
            && toCheck.getX() <= Math.max(start.getX(), end.getX())
            && toCheck.getY() >= Math.min(start.getY(), end.getY())
            && toCheck.getY() <= Math.max(start.getY(), end.getY())
            && toCheck.getZ() >= Math.min(start.getZ(), end.getZ())
            && toCheck.getZ() <= Math.max(start.getZ(), end.getZ());
    }
#

still the same thing

calm whale
golden turret
#

if you already have the start and end organized

golden kelp
#

I m sorry if thats wrong, its very confusing

golden turret
#

you dont need to call Math.min .max

golden kelp
#

okay

#

so what can be the reason its not returning true

hybrid spoke
golden turret
#

well

#

in this case

#

he should save the correct locations from the beginning

#

like when he did config.set

golden kelp
#

yes the locations are correct indeed

hybrid spoke
golden kelp
#

i got this idea

#

i can make an array of all the blocks from the start to the end of the portal
and then check if the player's location is in that array

#

bad for performance i think though

eternal oxide
#
return BoundingBox.of(start, end).contains(toCheck.toVector())```
golden kelp
#

oh

#
//Check if the player is in a portal and get which one is it
    public Portal getPortal(Player player) {
        for (Portal portal : vClasses.getPortals()) {
            if(BoundingBox.of(portal.startBlock(), portal.endBlock()).contains(player.getLocation().toVector())) {
                return portal;
            }
        }
        return null;
    }
#

it still says the portal is null

hybrid spoke
#

i would store the boundingbox in the portals instead of creating a new one every time

#

since when does BoundingBox exist?

golden kelp
#

wdym

#

since when does BoundingBox exist?
?

eternal oxide
#

If it still says its not a portal, your portal locations are wrong

hybrid spoke
#

?jd

golden kelp
eternal oxide
#

do yoru start/end cover only 1 pixel width? or the whole block?

golden kelp
#

the whole block

eternal oxide
#

if your start is Block#getX() etc, then your end shoudl be Block#getX()+1

sand orchid
#
public class PlayerMove implements Listener {

    @EventHandler
    public void PlayerMove(PlayerMoveEvent e) {

        if (e.getTo().getX() != e.getFrom().getX() || e.getTo().getY() != e.getFrom().getY() || e.getTo().getZ() != e.getFrom().getZ()) {

            Player p = e.getPlayer();
            PersistentDataContainer data = p.getPersistentDataContainer();
            data.set(new NamespacedKey(Main.getPlugin(), "PlayerMoving"), PersistentDataType.INTEGER, 1);
            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getPlugin(), new Runnable() {
                public void run() {
                    data.set(new NamespacedKey(Main.getPlugin(), "PlayerMoving"), PersistentDataType.INTEGER, 0);
                }
            }, 20L);
        }
    }
}
golden kelp
#

from this block to this one

eternal oxide
#

yes, you are only covering a single pixel wide

sand orchid
golden kelp
#

so what should i do now?

eternal oxide
#

your start is fine, but your end needs to be one block out

#

or at least 0.5

#

depending on portal orientation

golden kelp
#

and how do i find the portal orientation

eternal oxide
#

simpler would be, when you setup your portal scan the bounding box for portal blocks. Add each Block to a Set.

golden turret
#

@golden kelp

golden kelp
#

Yes?

golden turret
#

what will the portal do

golden kelp
#

just give the player some items

golden turret
#

how

eternal oxide
#

You end up with a Set of Block for that portal. In the portal event you can test using Set#contains(portalBlock)

golden kelp
#

by checking which portal it is, and each portal has a ItemStack[] in it

golden turret
#

i wanted somethin like "he will enter the portal" or "the portal will give items x seconds"

#

how will it be

golden kelp
#

ohh

terse raven
fierce jolt
#

Anyone experience with contributing to spigot? I have a tiny case I am unsure how to handle properly

sand orchid
undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

hybrid spoke
#

but you dont really want to create 2 NamespacedKey objects everytime your player moves his mouse

#

and probably also dont want to create a task everytime

golden turret
#

ok so

golden kelp
eternal oxide
# golden kelp Yes?

Tryjava return BoundingBox.of(start, end.add(1,1,1)).contains(toCheck.toVector())

golden kelp
#

Yes

golden turret
#

and check if getFrom is inside your portal

golden kelp
#

now I just need to find the orientation and then add based on it

eternal oxide
#

so long as it is an upright portal it will always be add(1,0,1)

#

you can safely do add(1,1,1) and that will handle end portals too

golden kelp
#

I just want nether portals

#

1,0,1
works for all orientations?

fierce jolt
#

So I am trying to write wrappers for advancements in minecraft since there is very to little possible right now. Even getting the name of the advancement is currently not possible.

I am struggling to create a good interface for the following enum.
Making an interface that returns the enum values is easy enough, but I would like to preserve the enum type in some way such that you can easily compare them in the api. Eg event.getAdvancement().getDisplay().getType() == AdvancementType.GOAL.
Now I could combine the 2 but that feels rather odd. Any idea on how to approach this?

eternal oxide
#

you are simply adjusting the end Location to cover teh whole width of a block in each direction

golden turret
# sand orchid wizardly can u help me check this ;-;

i would create an object for the player that would store his last action. you would listen for player events like move, eat and etc and set the last action to the current milliseconds. then you would have only 1 runnable to check if the last action minus now is greater than some value, like 3 seconds

eternal oxide
golden turret
#

does the portal frame stores the facing direction?

#

if ut does

eternal oxide
#

actually add(1,-1,1) would be better to use

#

no ignore that

eternal oxide
#

add(1,1,1) would be best

golden turret
#

start will be: start - portalBlockFace.getDirection().multiply(0.5);
end will be: start (after the change) + portalBlockFace.getDirection()

sand orchid
#

also my whole custom stat system is based off of persistentdatacontainers should i change that cause i dont rly wanna pull from a database everytime someone takes dmg

golden kelp
golden turret
#

yo

golden kelp
#
if(BoundingBox.of(portal.startBlock(), portal.endBlock().add(1,1,1)).contains(player.getLocation().toVector())) {
    portal;
}
golden turret
#

which material is used to set the nether portal frame

#

the puple thing

golden kelp
#

yes

golden turret
#

that was a question

eternal oxide
hybrid spoke
#

or do you mean obsidian?

golden kelp
eternal oxide
#

do you save your start/end?

golden turret
#

and which is the blockstate of the nether portal frame

eternal oxide
#

if you do you may have been modifying your end

golden turret
#

BlockData****

golden kelp
eternal oxide
#

one sec

golden kelp
#

wait i dont

#

i dont store them in a variable

#

i just call them, add 1,1,1 and pass it

terse raven
dusk flicker
#

it wants an object

#

as it says

terse raven
#

yea but when i then add a different function that wants an integer

dusk flicker
#

We need more info for anything else, what method, etc

terse raven
#

then it says the object already fullfills

#

that

terse raven
dusk flicker
#

it should be an object but its stupid

terse raven
#

well screw it ima do it separately then

#

thx tho

eternal oxide
# golden kelp i just call them, add 1,1,1 and pass it

Not tested, but this "should" find all portal blocks between your start/end. You can then simply call Set#contains on your portal block in yoru portal event to see if is this portal.

    public Set<Block> findPortal(Location start, Location end) {
        
        Set<Block> portal = new HashSet<>();
        World world = start.getWorld();
        
        for (int x = start.getBlockX(); x != end.getBlockX(); x += (start.getBlockX() < end.getBlockX())? 1: -1) {
            for (int y = start.getBlockY(); y != end.getBlockY(); y += (start.getBlockY() < end.getBlockY())? 1: -1) {
                for (int z = start.getBlockZ(); z != end.getBlockZ(); z += (start.getBlockZ() < end.getBlockZ())? 1: -1) {
                    Block block = world.getBlockAt(x, y, z);
                    if (block.getType() == Material.NETHER_PORTAL)
                        portal.add(block);
                }
            }
        }
        return portal;
    }```
golden kelp
#

ty

calm whale
humble tulip
#

@calm whale anything exceptions?

calm whale
#

nothing, the server just stop responding

humble tulip
#

How is the voronoi map preloaded or generated?

#

Do you do it as you're trying to gen the world or before?

calm whale
#

the voronoi is generated when I set my CustomBiomeProvider as BiomeProvider

#

I have this in my onEnable

#

It crash after "0"

humble tulip
#

Instead of returnΒ mapReader.getBiome(x, z)

#

Return the void

#

And see if it works

calm whale
#

yes it works

humble tulip
#

Ok

calm whale
#

I already tried it

#

I know where is the problem but I don't know why

river oracle
# calm whale

Crash report? Because creating a world can freeze the main thread

#

?paste

undone axleBOT
calm whale
#

nop useless

#

there is absolutly nothing in

river oracle
#

It's just creating the world then

#

Creating a world will freeze the main thread because the resources required to make a world

#

There is no fix for this

calm whale
#

so explain me something please

humble tulip
#

I dont understand why it crashes tbh

river oracle
#

Server creator lags the server natively as it's intensive

humble tulip
#

OH

river oracle
#

I have school rn but that's how world creator functions

#

You can't run it async either

humble tulip
#

@calm whale how many colors are there?

calm whale
#
private int count = 0;

    public MapReader(){

        voronoi = new Voronoi(2, 150);

    }
    public Biome getBiome(int x, int z){
        count++;
        System.out.println(count);
        return BiomesEnum.getBiomeFromColor(voronoi.getPixels()[x + Voronoi.SIZE /2][z + Voronoi.SIZE /2]);
    }```

Why does the count value never reach the 2048*2048 limit ?
humble tulip
#

Tbh for(BiomesEnum biomeΒ :Β values()){
Β  Β  Β  Β Β if(biome.getColor()Β ==Β color){
Β  Β  Β  Β  Β  Β Β returnΒ biome.getBiome();
Β  Β  Β  Β Β }
Β  Β Β }

calm whale
humble tulip
#

You should use a map here

calm whale
#

mmmmm

humble tulip
#

Instead of a for loop

calm whale
#

it's from an enum so...

humble tulip
#

How many biomeenums are there?

terse raven
#

is a map entry not an object??

humble tulip
#

It's a set

#

Wait

#

Lol

terse raven
#

yea

#

wtf

#

but this works

calm whale
eternal oxide
#

You are itterating it using Object

#

of course you are having to cast it

humble tulip
#

@calm whale throw in a while loop that never ends and see how long it takes fornthe server to crash

#

The only thing that makes sense is the server thinks that it's frozen and crashes

calm whale
#

why should I do that ?

calm whale
#

As I say it actually doesn't

humble tulip
#

It just stops?

calm whale
#

i'm on Paper and it detects when the server stop from responding.

The server doesn't stop by itself, I can't even shutdown it properly. Wait I make a video to show it.

golden kelp
eternal oxide
#

you don;t need to add() when using that findPortal

#

however

humble tulip
eternal oxide
#

I did say untested. Check the math on the for loops. I may have got the increment wrong

humble tulip
#

Try to not print the progress and use a map instead of a for loop

humble tulip
#

Nit sure if printing takes place on the main thread but it slows progress

calm whale
#

but how should I setup it ?

humble tulip
#

Setup the map?

#

Map<Integer, BiomeEnum>

#

For faster lookup

#

O(1)

calm whale
#

I know how to create a map, my question was where, but I figured out

humble tulip
#

Can do it anywhere tbh

#

In the biomeprovide class as a static block or on initialization

#

Maybe in the enum itself

#

Can't remember if that's possible

eternal oxide
# golden kelp o

On teh for loops change teh for lop end condition to != instead of <=

golden kelp
#

Still empty

calm whale
golden kelp
#
public Set<Block> findPortal(Location start, Location end) {
        Set<Block> portal = new HashSet<>();
        World world = start.getWorld();

        for (int x = start.getBlockX(); x != end.getBlockX(); x += (start.getBlockX() < end.getBlockX())? 1: -1) {
            for (int y = start.getBlockY(); y != end.getBlockY(); y += (start.getBlockY() < end.getBlockY())? 1: -1) {
                for (int z = start.getBlockZ(); z != end.getBlockZ(); z += (start.getBlockZ() < end.getBlockZ())? 1: -1) {
                    Block block = world.getBlockAt(x, y, z);
                    if (block.getType() == Material.NETHER_PORTAL)
                        portal.add(block);
                }
            }
        }
        return portal;
    }
golden turret
#

bro

calm whale
#

But its still blocked

golden turret
#

are you at this?

eternal oxide
golden kelp
#

Oh, np, and ty

golden turret
#

i had a philosophy lesson

#

wnt to interval

#

and you still are talking about portals

golden kelp
#

yea sadly

golden turret
#

if

#

you say to me

golden kelp
#

to me

golden turret
#

the blockdata of the portal frame

#

you can have a help that will end this

#

check it for me

golden kelp
#

okay

golden turret
#

in something like PlayerInteractEvent

#

get the block

#

do a sout in the .getClass.getName

golden kelp
#

yea done

golden turret
#

show it pls

golden kelp
#

CraftBlockData{minecraft:air}

#

weird

golden turret
#

ok

#

use setBlock

#

then get the block at that location

#

and get the class name

#

and print

golden kelp
#

use setBlock
for what location?

golden turret
#

it is just for a test

humble tulip
#

Do you use intellij @calm whale

#

You can use the debugger to see what's going on

calm whale
#

I do

eternal oxide
#

nope I was correct first time !=

golden kelp
#

the set was null that time

quaint mantle
#
INSERT IGNORE INTO player_data (uuid, money, chips, team) VALUES (?, ?, ?, ?);```
#

For some reason, it inserts it again.

calm whale
#

But how to use it with a plugin ? I build the jar with maven direct*ly into the plugins folder of my server then I start it into Intellij

golden kelp
#

@golden turret so when I do set, it sets the portal purple thing to water

calm whale
#

Even if I launch my build in debug mode there is no debug available because it's running in a third party

#

Intellij is only hosting the terminal window of my bat script

golden kelp
humble tulip
calm whale
#

Do you have any link or keyword to search on google ?

humble tulip
#

Intellij debugger spigotmc

golden turret
humble tulip
#

There's a page on how to do it

calm whale
#

indeed

humble tulip
golden kelp
humble tulip
#

Is that where the output stops

golden kelp
#
[18:27:54] [Server thread/WARN]: Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
[18:27:57] [Server thread/INFO]: LEGACY_AIR(0)
calm whale
#

I can't stop the processs even with ctrl+c

golden turret
#

@golden kelp alright

humble tulip
#

It stops when the otherbthread starts

#

Maybe a deadlock

golden turret
#

i will get home in 2 hours

#

i will do it for you

golden kelp
#

o

#

ty

humble tulip
#

Make the map and array concurrent

worldly ingot
#

Ideally your UUID would be a PRIMARY KEY

calm whale
humble tulip
#

Ye

#

Think the array causes a deadlock when being accessed by multiple threads

worldly ingot
#

i.e. before you executed that statement? Or you've done it just now?

humble tulip
#

Pixels array

calm whale
#

ah ok

humble tulip
#

Also don't remove the map even though it didn't solve ur issue

#

It's still faster that way

crimson terrace
#

If I install NMS for 1.16.1, what Minecraft versions will it be compatible with? just 1.16.1?

calm whale
#

And how can I achieve this ?

#

I have to change their type to an atomic one ?

humble tulip
#

I dont know too much abt concurrency so I'd use a map

#

Concurrent hashmap

#

Map the xz coords to the pixel

calm whale
#

So I transform the pixel array to a ConcurrentHashMap too ?

humble tulip
#

Create a coordinate object that holds x and z with a equals and hashcode method

calm whale
#

same for the HashMap biome color ?

humble tulip
#

Yes make it concurrent as well

#

This not necessarily the most efficient solution but it should fix your issue

#

Then you can optimize afterwards

golden kelp
#

Can you add fake lights around a player?
I want to make a spotlight effect.
My plan was to add lanterns around the player (invisibile) as I also want to change the colour (red/blue)

#

and if my plan is good, can I also increase the intensity

glossy venture
#

there is something called LightAPI

kind coral
#

I DID A NOT SO GOOD THING

#

i published my premium resource for free and posted an update how do i remove the resource

golden kelp
#

oof

kind coral
#

@vagrant stratus

#

could you remove my resource please? ASAP

#

@vagrant stratus sorry for the pings but i kinda need ur help asap :/

calm whale
#

nop @humble tulip sadly it didn't fix it

golden kelp
golden kelp
dense geyser
#

where you see hidden class stuff like the Bukkit class which invokes methods of classes that spigot-api doesn't have access to, is there a name for that type of coding?

golden kelp
#

oh

#

i was looking at their github

#

ty

#

I want to make it so the light follows the player all the time

#

so, on the player move event, i spawn a new light? and remove the old one?

humble tulip
#

?

golden kelp
humble tulip
#

Well same result?

calm whale
#

Same problem I would say like we do not have any error

#

yep

worldly ingot
humble tulip
#

Just realized im dumb

#

You could've just made the method synchronized

worldly ingot
#
public final class Bukkit {

    private static Server server;

    public static void setServer(Server server) {
        Bukkit.server = server;
    }

    public static Server getServer() {
        return server;
    }

    public static BlockData createBlockData(String data) {
        return server.createBlockData(data);
    }

}```
humble tulip
#

@calm whale can you add the debug statements back for count and send the output?

worldly ingot
#

If that gives you any indication of how it works. CraftBukkit calls setServer()

#

It's how Bukkit and CraftBukkit are "linked"

calm whale
#

it stop exactly at the same number

humble tulip
#

Exactly the same?

#

Wtf

calm whale
#

yes

#

12223

humble tulip
#

Is map you generate random?

calm whale
#

yep

#

the voronoi and it's colors are random

humble tulip
#

Run it again see if it stops at the same number

eternal needle
#

hi i got this code and when the command be don it say player not found

                    //Get name
                    String name = e.getClickedInventory().getItem(4).getItemMeta().getDisplayName();
                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco take " + name + " 1000");
                    player.sendMessage(ChatColor.GREEN + " Player");```
calm whale
#

it stops at this number since I'm stuck on this xD

humble tulip
#

Oh wow

#

What's so special abt that number

#

Does it stop when it switches to another thread?

#

As it did before?

calm whale
#

I renember I did something similar and it was working well

humble tulip
#

Look at the log, you'll see the thread

#

That it logs from

calm whale
#

server logs ?

#

nothing special

#

OH yes !

#

mb

#

indeed

#

its on the thread switch

humble tulip
#

Reverd to your old getpixel method

#

But just make it synchrnised

#

And make sure everything else is thread safe

#

You should make a thread on discord tbh

crisp steeple
river oracle
#

It's okay we wait till he releases server with plygin and abuse it

quaint mantle
#

@crisp steeple i like ur background

eternal needle
crisp steeple
crisp steeple
#

not the api for whatever economy plugin you’re using

glossy venture
#

bad

crisp steeple
#

i could click whatever button that is and then in the same tick pay someone all my money

#

and it would try to take money that i don’t even have from me

worldly ingot
#

I've always said that if you're using commands in your plugin, you might as well be using command blocks

#

Take a look at Vault. It will help you interact with economies more fluidly

eternal needle
glossy venture
#

vault

eternal needle
#

ok

shut field
#

Prolly should’ve turned ping off

#

But can’t change that now.

shadow pulsar
#

Is there a more efficient way to get exp from level without using a while loop? It severely lags the server at high levels.

private int getExpToLevel(int level){
        if(level >= 0) return (int) (Math.pow(level + 1, 2) + (5 * (level + 1)));
        return 0;
    }
    private long getExpFromLevel(int level){
        if(level < 1) return 0;
        long totalExp = 0;
        while (level > 0){
            level--;
            totalExp += getExpToLevel(level);
        }
        return totalExp;
    }```
subtle folio
#

Am I able to just include JDA in my plugin to make it link to a discord bot?

humble tulip
#

Just don't call jda on the main thread

#

It works idk if it's the best practice

subtle folio
#

hm alright

ivory sleet
subtle folio
#

link me docs pls

shadow pulsar
ivory sleet
#

that depends on how your level system is built up

humble tulip
#

And getlevelfromexp

#

Are they opposite methods

#

Like one does the opposite of the other?

#

The names are confusijg me tbh

#

Getexptolevel

shadow pulsar
#

getLevelFromExp gets the total amount of exp from that level. So, if you are level 1 should return 6, level 2 should return 20, level 3- 44.

crisp steeple
ivory sleet
shadow pulsar
#

getExpToLevel is the amount of exp needed to get to the next level

humble tulip
#

Shouldn't the top one be getlevelfromexp and the variable be exp

#

Not level

#

It's throwing me off

#

I'll see the get the inverse of the eqn for u

#

Might be a quadratic

shadow pulsar
humble tulip
#

So you want a more efficent way to get the amoint of xp needed to get to the next level?

shadow pulsar
#

No, I want a more efficient way to get the total exp from level, without using a while loop.

#

I've tried multiple equations but I couldn't find one that works for all levels.

humble tulip
#

level^2 + 6 Γ— level (at levels 0–16)
2.5 Γ— level^2 – 40.5 Γ— level + 360 (at levels 17–31)
4.5 Γ— level^2 – 162.5 Γ— level + 2220 (at levels 32+)

shadow pulsar
#

I'm using a custom exp system.

humble tulip
#

so if level < 17 then do the frist eqn

#

oh

#

well how do you convert xp to levels?

shadow pulsar
#

I don't. I have exp and level cached. When exp gets added, if it is at or above getExpToLevel() then level gets added and exp = 0. I don't store the complete total amount of exp that was collected, hence why I am trying to get it using an equation.

humble tulip
#

@shadow pulsar (18 + 29 n + 12 n^2 + n^3)/3

twilit roost
#

How can I remove NPC from server? using NMS

I have tried ```java
npc.getBukkitEntity().remove();

and ```java
ps.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER,npc));
humble tulip
#

try that formula

#

1/3 (n + 1) (n + 2) (n + 9)

#

which is that

#

n is the level

#
private int getExpFromLevel(int level){
    if(level >= 0) return (level+1) * (level+2) * (level+9)/3
    return 0;
}
twilit roost
humble tulip
quaint mantle
#

How do I run a scoreboard loop async ?

humble tulip
#

BukkitRunnable#runTaskTimerAsynchronously

wind tulip
#

Are there any real benefits to using maven?
I know that it combines all the dependencies into one jar (uber jar) which might help with performance or whatever it is, however I find it more confusing than it needs to be.
Would it be bad if I just used vanilla java to make my plugins? It might be considered "bad practice", but aside from that?

ivory sleet
#

yes

#

transitive dependencies

#

and modularity

#

you're still using vanilla java

humble tulip
#

if he's making simple plugins and just needs to import vault and some library which he will shade into the jarfile. maven is not necessary imo

#

i guess it depends on the use case

ivory sleet
#

using maven or gradle is always a smart decision