#help-development

1 messages · Page 1358 of 1

eternal oxide
#

what resource folder?

#

a resource folder is in yoru project but is not transfered to yoru jar

#

an common library?

#

those are either in the libs folder at the root of your server or you are using the wrong terminology

#

Lastly, if its a common library, why are you decompiling anything?

kindred solar
#

ahh, now i see

#

but it returned 3 different jar filles

#

1 original

#

1 shaded

#

and 1 "normal"

#

i think im going to do my database with local filles

#

i think its better

young knoll
#

SQLite is nice

#

And spigot already bundles the driver

bright jasper
#

There schema.sql is in the resource folder, it gets copied to the jar(proven by decompiling the jar)

eternal oxide
#

!decompiling. Its just a zipped jar.

#

however. all contents of the jar can be accessed using getResource() which is the correct way to access it

#

getResource() returns an InputStream

bright jasper
#

its a library used by other plugins

eternal oxide
#

agnostic?

#

Pretty sure God has no place in this

bright jasper
#

It is a library in maven used by two plugins, bungee and spigot, i need to get the resource from the inside the jar

#

platform agnostic is terminology

#

for does not rely on a singular API

#

structure

#

need to get schema.sql

eternal oxide
#

so you have a file in your jar you want to access from both spigot and from Bungee

bright jasper
#

Not what I am talking about, the myriadcommon is a dependency of a plugin in both spigot, and bungee

eternal oxide
#

Stop trying to use flashy words, and explain in basic english what you are trying to achieve

bright jasper
#

These are basic words that tell you what I am trying to do. This MyriadCommon module in maven(official terminology) is a dependency of two separate plugins, a spigot plugin and a bungeecord plugin. Usually in java you can embed a resource in the resources folder and fetch it with this getClass().getResource("schema.sql"). This seems that it does not work and returns null when used in bungee/spigot plugin. Unzipping the jar shows me that the schema.sql is still there

#

I cannot do this because its not inherently bukkit or bungee plugin. It is a library used by both, and I need to get the resource from both

#

Also that terminology is almost official everywhere in the software development world

eternal oxide
#

you have to use the correct ClassLoader to access the resources. It has the be the ClassLoader that loaded the plugin jar itself

bright jasper
#

So it needs to be loaded/fetched in something that extends Plugin

#

or JavaPlugin

eternal oxide
#

is the library being loaded via your plugin or by Spigot/Bungee?

bright jasper
#

The library isnt really being loaded by them as a plugin but it is being accessed from the plugins

eternal oxide
#

I don't recognise it as anythign shaded by Spigot/Bungee, so I'll assume its yoru plugin shaded

bright jasper
#

in the form of

#
database = new Database(config.getString("mysql.url"), config.getString("mysql.username"), config.getString("mysql.password"));

database is in the common library

#

Yeah its shaded

#

Well i didnt specify it being shaded but its a maven project with modules so it is shaded in the end result i think(plus it runs normally lmao, so yes shaded)

eternal oxide
#

try using plugin.class.getClassLoader().getResource(arg0)

#

as that will guarantee you are usign teh ClassLoader that loaded your plugin, no matter if it was spigot or bungee

bright jasper
#

plugin is?

eternal oxide
#

your plugin main class instance

bright jasper
#

Ah so since i initialize the database in myriadcommon ill just make the classloader an arg

deft sedge
#

How do I make it add a specific amount of the item ep?

young knoll
#

ItemStack.setCount

deft sedge
#

ok

#

thanks

young knoll
#

Also don’t forget setItemMera

deft sedge
#

yea

#

i just rememberd that

#

thx lol

dusty herald
#

would be nice to see the whole code though, you could just do new ItemStack(Material, Integer)

deft sedge
#

well the number depends per if statement

#

so i think i'll just set the item cound in the if statement

#

but there's the code

young knoll
#

Forgot about setting it in the constructor, probably a better idea

dusty herald
#

well they plan on changing the item's amount multiple times ig? thonk

deft sedge
#

yea

#

I need it to be different if they have a white bed or a green bed

dusty herald
#

can I see the code for checkForItem

deft sedge
#

yea

dusty herald
#

just curious

deft sedge
dusty herald
#

why not just have it return a boolean instead of a string?

deft sedge
#

idk

dusty herald
#

wait what

deft sedge
#

I like strings i guess

dusty herald
#

yeah just have it return a boolean, so you could do something like:

if(findItem.checkForItem(player1, Material.WHITE_BED)){

}```
deft sedge
#

yea

#

ik

young knoll
#

Yeah that is some wack code

dusty herald
#

also you should read up on some naming conventions

deft sedge
#

ik is supposed to be lowerThenUpper

dusty herald
deft sedge
young knoll
#

Yeah

#

Sorry wrong name

deft sedge
#

lol it's ok

#

intelij is smart

dusty herald
#

what happen

deft sedge
#

How do i remove a certain amount of a certain material from a players inventory

deft sedge
#

k

quaint mantle
#

Hey how do i disable something like "You logged from another location." but on BungeeCord

#

Good morning

#

Does anyone know about a good job Plugin for economy-based Server?

quaint mantle
#

Any better ways to use TabCompleter?

#
public final List<String> onTabComplete(CommandSender s, Command cmd, String alias, String[] args) {
        if (s.hasPermission("roomicommands.others.ci")) {
            return null;
        } else {
            return Collections.emptyList();
        }
    }```
narrow furnace
#

👀

quaint mantle
quaint mantle
#

ShopGUIPlus

#

Or EssentialsX's Sign Shop [BUY] [Sell]

#

Disabled by Default in config

#
enabledSigns:
  #- color
  #- balance
  #- buy
  #- sell
  #- trade
  #- free
  #- disposal
  #- warp
  #- kit
  #- mail
  #- enchant
  #- gamemode
  #- heal
  #- info
  #- spawnmob
  #- repair
  #- time
  #- weather```
#

You can enable it in plugins/EssentialsX/config.yml

quaint mantle
#

I need help. how to get all bossbars in server with foreach? (I tried many things that i can, but I coludn't do)

onyx shale
#

bukkit/server .getBossBars

#

returns a iterator for some reason though

blazing grove
#

Hello i need help

#

If my plugin run this my connection is "crash"

onyx shale
#

well its rather straight forward

#

you cant do commands async

#

you have to move to main thread before dispatching

blazing grove
#

If i make a delayed task it do the work?

onyx shale
#

just make a normal task runnable

blazing grove
#

Ok ty very much!

onyx shale
#

.runTask

quaint mantle
onyx shale
#

you need to use the iterator specific looping

#

not a foreach

quaint mantle
#

ty

sullen mulch
#

how do i fix this?

quaint mantle
#

How can I make my own challenges gui? (Like this picture) (This is possible. I'm sure.)

quaint mantle
#

thanks but I saw it on 1.12.2 server

#

1.12.2 ~ 1.16.5 server

#

but based on 1.12.2

#

I dont know if its possible or not but im sure you can do it in 1.16

#

ok thanks, but I couldn't found result on google

#

of course, I already googled before question

reef mulch
#

Please decipher

outer crane
blazing grove
#

Thanks for the advice i will check them

reef mulch
limber dust
#

config is not formatted well

quaint mantle
#

hey how do i get if the server is full by using ServerInfo or convert ServerInfo to Server? bungeecord

limber dust
urban trout
#

hey can anyone help me with adding placeholders to my scoreboard

#

i cant find any tutorials that show a scoreboard one

limber dust
#

hook into papi

urban trout
#

i put it in the external jar things

limber dust
#

PlaceholderAPI.setPlaceholders(player, x); thats the code you need to use papi placeholders

urban trout
#

so would i replace the obj.getScore?

#

or put it in the obj.getScore( bit )?

limber dust
#

yes and make x be the string you want to change

urban trout
#

okay

odd bronze
#

How can I open chest silently? Without any animations? Currently I'm opening chest normally but with animation and if chest is doubled then only 1 part is opening.
Code: java @EventHandler public void onPlayerInteract(PlayerInteractEvent event){ Player p = event.getPlayer(); Block block = event.getClickedBlock(); if(block != null && event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (CHESTS.contains(block.getType())) { if(vanished.contains(p)) { event.setCancelled(true); Inventory inv = ((Chest) block.getState()).getBlockInventory(); p.openInventory(inv); } } } }

quaint mantle
#

well first of all you are getting the block inventory so you are only getting one chest because of that

urban trout
quaint mantle
#

so instead of using getBlockInventory use just getInventory

urban trout
# urban trout i dont think it worked

Score score7 = obj.getScore(PlaceholderAPI.setPlaceholders(player, "%statistic_kill_entity:Zombie%")); score7.setScore(7);
is underlined in yellow

worn tundra
#

hover over it

#

and read what it says

#

...

quaint mantle
#

and probably the best way is using packets to not see the animation @odd bronze

urban trout
#

Add @SuppressWarnings to createBoard or to deprecation or smth

#

I tried both and it still didnt show up

#

Description Resource Path Location Type The method getScore(OfflinePlayer) from the type Objective is deprecated Main.java /rennsb/src/me/renndrew/scoreboard line 54 Java Problem

#

line 54: Score score7 = obj.getScore(PlaceholderAPI.setPlaceholders(player, "%statistic_kill_entity:Zombie%"));

quaint mantle
#

hi, how could I set as join message an arraylist from the config file?

#

I tried to do a for loop but it only sends one line

humble stirrup
#

wdym

#

that's a bit vague

limber dust
quaint mantle
humble stirrup
#

what is your arraylist?

#

are you trying to create multiple lines?

#

just join them with '\n'

quaint mantle
#

but what if my config has:

JoinMessage:
- "Hello %player%!"
- "Welcome to my Server"
- "Hope you don't leave :D"
limber dust
humble stirrup
#

yeah use String.join

quaint mantle
#

String.join?

quaint mantle
#

I remove the for loop?

humble stirrup
#

correct

quaint mantle
#

nothing XD

#

it sends only 1 line

humble stirrup
#

what's your code

quaint mantle
#
@EventHandler
    public void onJoin(PlayerJoinEvent e) {
        fl = new FileListener(main);
        FileConfiguration msgFile = fl.getMessages();
        Player player = e.getPlayer();
        if(!(Bukkit.getOfflinePlayer(player.getUniqueId()).hasPlayedBefore())) {
            List<String> firstJoinMessage = msgFile.getStringList("Events.FirstJoin");
            for (String asd : firstJoinMessage) {
                String msgJoin = String.join("-", asd);
                e.setJoinMessage(msgJoin);
            }
        }else {
            e.setJoinMessage("Not first time");
        }
    }
#

oh ok

#

the for loop

limber dust
#

put the set message method under the forloop

quaint mantle
#

hmm

humble stirrup
#

e.setJoinMessage(String,join("\n", msgFile.getStringList("Events.FirstJoin"))

#

surely?

humble stirrup
#

no?

quaint mantle
#

The method join(CharSequence, CharSequence...) in the type String is not applicable for the arguments (char, List<String>)

#

I try toString()?

#

nothing

#

XD

humble stirrup
#

ah you may have to get it as an array

#

List#toArray is what you need for that

quaint mantle
#

The method join(CharSequence, CharSequence...) in the type String is not applicable for the arguments (char, List<String>)

#

wait

#

not that error

#

The method join(CharSequence, CharSequence...) in the type String is not applicable for the arguments (char, Object[])

#

that one

vivid cave
#

where can i check the logs file of my minecraft server

#

i mean the file that stores the console

#

the recent console logs

quaint mantle
#

in the logs folder

rotund ravine
#

Your . Was a ,

humble stirrup
#

wat

rotund ravine
#

Also that method works fine

#

For lists

limber dust
#

omg i see the , now XD

quaint mantle
#

bruh

#

I know why it doesn't work

#

the setJoinMessage can't get multiple lines I think

#

but the player.sendMessage can

limber dust
humble stirrup
#

you're concatenating them down into one line

lost matrix
lost matrix
quaint mantle
quaint mantle
humble stirrup
#

you need to just concatenate the list into a string

#

this is pretty basic stuff

quaint mantle
#

yeah it works thx xd

#

buy I have a little bug

#
  - "&m                                  "
  - "&aWelcome &e%player% &ato &cMyServer"
  - "&bLet's welcome &e%player%&b!"
  - "&m                                  "
#

that's my list

humble stirrup
#

let me guess

#

no colours?

quaint mantle
#

the last line appears with &b color

humble stirrup
#

ChatColor.translateAlternateColorCodes

quaint mantle
#

I tried to do &r and &f but still in blue

#

I know how to translate the colors XD

#

look

humble stirrup
#

is that not expected

quaint mantle
#

I can't send img :c

humble stirrup
#

if you want to reset it add &r to your delimiter

#

verify for images

quaint mantle
#

hey , why when i export a plugin with maven the dependency is in the plugin (ex. bungeecord)

humble stirrup
#

set scope to provided

quaint mantle
#

my pom.xml

humble stirrup
#
<dependency>
  <groupId>whatever</groupId>
  ...
  <scope>provided</scope>```
quaint mantle
#

i do have it like that

humble stirrup
#

how are you exporting it?

#

clean package?

quaint mantle
#

is there any way i could hide the senders name of a message in chat through the AsyncPlayerChatEvent

humble stirrup
#

ah i see why

quaint mantle
humble stirrup
#

lose the shade plugin config

humble stirrup
#

one or the other

quaint mantle
#

wait so how do i export maven?

humble stirrup
#

mvn clean package

#

jar is in target

quaint mantle
#

and where do i write the mvn?

humble stirrup
#

i dont use eclipse so idk if there's some kind of wrapper around it

#

terminal

quaint mantle
#

okeyy

#

and the pom.xml is alright or?

humble stirrup
#

lose the build plugins section then yes, its fine

quaint mantle
#

okay

odd bronze
quaint mantle
#

gg just fixed the bug 😄

lost matrix
odd bronze
#

I havent check it yet

lost matrix
#

There is a way where you use a proxy inventory and mirror all click and drag events to the original inventory (and vise versa).

#

Thats the non packet way

odd bronze
#

🤔

lost matrix
# odd bronze 🤔

There might be a way using nms...
Do you want to keep version compatability?

odd bronze
#

I'm currently at 1.16.4 and Im doing everything on it

#

so I think yes

#

so what do you think? @lost matrix

wide dune
#
ItemStack sword = new ItemStack(Material.GOLD_SWORD);
            ItemMeta im = sword.getItemMeta();
            im.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&6&lGod Sword"));
            im.setLore(Collections.singletonList(ChatColor.translateAlternateColorCodes('&', "&7Only to be used by gods!")));
            im.spigot().setUnbreakable(true);
            
            sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 100);
            sword.setItemMeta(im);```
#

why is the sword unenchanted?

unreal quartz
#

because you overwrite the item meta right under it

#

apply it to im instad

vital ridge
#

does anyone know why entitytarget event is not working correctly with hoglins & zoglins?

#

Im cancelling the target event for them

#

they dont attack me first anymore

#

but if i punch them, they still attack me

#

which it shouldnt do

#
@EventHandler
    public void onWrongTarget(EntityTargetLivingEntityEvent e) {

        if (main.getConfig().getBoolean("hostile-mobs-attack") == false) {

            if (e.getEntity() instanceof Zoglin) {
                if (e.getTarget() instanceof LivingEntity) {
                    
                    e.setCancelled(true);

                }
            }

        }

    }
vital ridge
#

But e.setcancelled works with all the other mobs

#

theys never attack me

#

the issue only occurs with zoglins and hoglins

#

but ill try it

river spear
#

How do I get the location for every gold block. The green wool has the coordinate -52 76 -66. And the way to the gold block is with a vector to (5, -1, 3).

abstract relic
#

rotate the vector by 90 degrees

#

3 times

solemn shoal
#

question, how can i clear a specific nbt tag in a tile entity?

#

ive tried this but it completely resets the furnace

opal juniper
#

Ok, so i have a PacketPlayOutMapChunk packet which is then put into a PacketContainer. I currently then modify the packet like this:
(wrappedPacket is the PacketContainer)

if (fillWithAir) {
            wrappedPacket.getByteArrays().modify(0, bytes -> {
                Arrays.fill(bytes, (byte) 0);
                return bytes;
            });
        }

In order to essentially 'void' the chunk as it just overwrites all blocks with air. However, instead i would like to have it like this:

#

Where the ‘south’ row of blocks are all left behind. However, I am not too familiar with the byte arrays and would appreciate some pointers! 😄

abstract relic
weary geyser
#

Is there any good alternatives to morphia?

#

except Jongo

lost matrix
weary geyser
#

Morphia causes alot of errors for me

#

I have tried to fix them for like a week

#

I've just given up

#

at this point

river spear
lost matrix
# weary geyser Morphia causes alot of errors for me

Morphia is the most popular odm for a reason. If it throws errors then you are probably misusing the library.
Using any mapper has to flow into your design process when you start writing your application. You cant just
throw any mapper in at some point and expect it to work.

How much experience do you have with using the plain mongodb driver for persisting objects?

weary geyser
#

Not much

proper notch
#

Jackson + mongodb is the sexiest thing to exist

lost matrix
# weary geyser Not much

Then scrap the idea of using ODMs or ORMs. Its an extra abstraction level for people who have
experience with the underlying database architecture so they dont need to write the boilerplate code
they have written several times already.

How much experience do you have with serializing Objects into Json? Like with Gson or Jackson.

proper notch
#

mongodb on its own is a bit of a pain

lost matrix
# weary geyser Not much either

Then also scrap the idea of using document databases. Step one:
Serialize your objects to .json files and deserialize them back from .json files.
You can use Gson (which is build into Spigot) or Jackson for that.

After that you can use that code + your gained knowledge to easily get into document based databases like mongoDB.

weary geyser
#

@lost matrix Alr, but one question. When I use mongodb it spams Opened connection [connectionId{localValue:2, serverValue:21499}] to database and then creates 50 objects with the same ObjectId

lost matrix
weary geyser
#

I've worked a while with morphia

#

But yes it's the first database

#

thing

lost matrix
#

So you are skipping

  • Simple (de-)serialisation
  • Persisting objects to arbitrary Strings like yaml
  • Database architecture
  • Connections and connection handling
  • Connection pooling
  • Simple Json (de-)serialisation
  • Document based vs Relational based comparison
  • Manual mapping from json to bson
  • Automatic mapping with mapper tools like ORMs and ODMs
  • Auto persisting with morphia < -- You are here. Most of the steps above are a hard dependency for understanding mophia. (Like connection handling)

You skipped a lot of important steps in learning morphia. No idea who told you to jump right into that but its a bad idea because you will be confused for months.

Step one is saving your objects into plain .json files. Thats where you should start. Gson is pretty easy to understand and there are some great tutorials on that.
@weary geyser

abstract relic
lost matrix
abstract relic
#

oh lol since when what the hell

quiet ice
#

basically forever

#

Probably almost a decade

ivory sleet
#

Lol ye

quaint mantle
#

Whats the best way to set a spawn location for a player?

opal juniper
#

?jd

opal juniper
quaint mantle
#

teleporting the player on join doesnt seem right to me

opal juniper
undone pebble
quaint mantle
undone pebble
#

What? Lol

quaint mantle
#

What?

#

Executing too many actions before PlayerJoinEvent will just kick the player

undone pebble
#

Before PlayerJoinEvent? Are you referring to Async/PlayerLoginEvent

quaint mantle
#

Dont know, but I had issues with it recently

undone pebble
#

Adding a delay happens after the event

quaint mantle
#

Yes

undone pebble
#

👍 thought you got confused in regards of that

solemn shoal
#

question, how can i invoke a random tick?

#

like, the system that makes farms tick

minor fox
#

@quaint mantle be careful, teleporting players on join might cause visibility issues

minor fox
#

you should use playeronspawnevent

quaint mantle
#

THANK YOUUUU

minor fox
#

PlayerSpawnLocationEvent*

quaint mantle
#

That was exactly what I was looking for , thx

young knoll
undone pebble
#

Never knew that, thanks Ferskfisk

opal juniper
solemn shoal
#

hm

quaint mantle
#

Hey, how can I round a double to 2 decimal places? I have looked a lot on the internet but somehow nothing worked out.... I have a BlockBreakEvent and every time the player takes down a sand, then 0.45 is added. 🥲

unreal quartz
#

there are many ways to do this, which a simple google search will yield

young knoll
#

String.format lets you do that

#

And DecimalFormat

lost matrix
young knoll
#

There are definitely more than 2 ways

solemn shoal
#
DecimalFormat df = new DecimalFormat("#.##");
df.format(number);```
#

thats how I do it at least

quaint mantle
solemn shoal
#

it should work

#

I mean, it works fine for me

young knoll
#

19ns per tick? Did you rip out all of the poor games functions

#

Or is that an M

paper viper
#

thats an M

young knoll
#

I never noticed how weird the font is

solemn shoal
#

thats an M

paper viper
#

its ok Col

#

we are all blind at the end of the day

unreal kayak
#

what is the best way for saving player stats?

Caching and know updates by plugin messaging
CompletableFutures for IPlayers and caching some for placeholders```
paper viper
#

please don't name your interfaces like IPlayer

#

or that crap

raven vine
unreal kayak
paper viper
#

just don't name it that...

#

please

young knoll
#

Having boss bars for that stuff is neat

solemn shoal
#

yeah @young knoll

unreal kayak
#

then I name is Player

solemn shoal
#

monitoring 100

paper viper
#

do you use oshi

#

for that

solemn shoal
#

who, me?

paper viper
#

yes

solemn shoal
#

no

paper viper
#

oh what do you use then

solemn shoal
#

or what do you mean by oshi?

paper viper
#

one sec let me pull it up

raven vine
#

I need like a MMOItems plugin in 1.16.5 (sorry for english lul)

paper viper
#

not the place

raven vine
#

oh

#

ok sorry

paper viper
lost matrix
# quaint mantle that was what i was trying 2 do

The one just truncates the double the other one formats it with the given options.

  public static double truncateDecimalPlaces(final double value, final int decimals) {
    double scale = Math.pow(10, decimals);
    return (int) (value * scale) / scale;
  }

  public static String format(final double value, final int decimals) {
    String formatString = "#." + "#".repeat(decimals);
    return new DecimalFormat(formatString).format(value);
  }
daring sierra
solemn shoal
#

im using com.sun.management.OperatingSystemMXBean

paper viper
#

import com.sun.management.OperatingSystemMXBean;

#

thats why

solemn shoal
#

yeah

paper viper
#

and also

lost matrix
#

This intendation

paper viper
#

hmmmm

#

lol

solemn shoal
#

what about the indentation lol

paper viper
#
                if(players>0) entTitle += "Player " + players + " ";
                if(items>0) entTitle += "Item " + items + " ";
                if(minecarts>0) entTitle += "Cart " + minecarts+ " ";
                if(peaceful>0) entTitle += "Peace " + peaceful+ " ";
                if(hostile>0) entTitle += "Hostile " + hostile+ (others==0?"":" ");
                if(others>0) entTitle += "+" + others;

#

🥲

lost matrix
#

And stacked blocks...

paper viper
#

do you know your ide has an auto formattter

#

right

paper viper
#

(:

paper viper
#

im not talking to you

solemn shoal
#

that is autoformatted

#

lol

paper viper
#

O.o

raven vine
#

what's code

#

sorry

#

i just

#

I just wondered

paper viper
#

okay

#

then

quaint mantle
#

@lost matrix , @solemn shoal thanks! now it worked : )

solemn shoal
#

i swear that code is autoformatted

solemn shoal
#

it reduces the length of the bossbar lol

paper viper
#

!_!

solemn shoal
#

when applicable*

last lintel
#

guys can somebody help me?

#

im trying to teleport to another world

#

but it wont work

solemn shoal
#

yeah what about the onenable

lost matrix
last lintel
#

ok

#

@EventHandler
public void onRightClick(PlayerInteractEvent event){
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(event.getItem() != null){
if (event.getItem().getItemMeta().equals(ItemManager.Survival.getItemMeta())){
Player player = event.getPlayer();

                player.teleport(new Location(Bukkit.getWorld("LoTooS2"), 260, 68, 270, 0, 0));
            }
        }
    }
}
lost matrix
last lintel
#

yes

#

do i need to mention the world or something?

lost matrix
#

player.teleport(Bukkit.getWorld("LoTooS2").getSpawnLocation());

last lintel
#

i only put it in the root server dir

lost matrix
last lintel
#

wdym?

solemn shoal
#

how would you even load a world in code?

#

Bukkit.createWorld?

dusk flicker
#

Create the world

#

yes

#

That loads it if it already exists

lost matrix
#

Is the world your main world or did you manually load the world by using the WorldCreator class?
Because Spigot doesnt just randomly try to load every folder thats in your directory.

last lintel
#

in the onEnabled function?

#

i did neither of those

lost matrix
last lintel
#

i just put it in the root

#

folder

lost matrix
last lintel
#

how?

solemn shoal
#
WorldCreator worldcreator = new WorldCreator("name");
worldcreator.environment(Environment.NORMAL);
Bukkit.createWorld(worldcreator);```
#

yes that code could be shorter but it works

last lintel
#

what if i want to use a world i downloaded?

solemn shoal
#

same code

#

if it already exists, itll load it

last lintel
#

ok

#

thank you all so very much

ivory sleet
#

Np

lost matrix
# last lintel how?
  public World loadWorld(final String worldName) {
    final File worldFolder = new File(Bukkit.getWorldContainer() + File.separator + worldName);
    if (!worldFolder.exists()) {
      return null;
    }
    return WorldCreator.name(worldName).createWorld();
  }

This doesnt check for the world type so it only works for default worlds.

solemn shoal
#

does anyone here have experience with NMS? if so, i have a CraftServer instance, how can i force a tick

#

or set a tickrate that isnt 20

green prism
#

Guys, this code: orangeglassmeta.addItemFlags(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_UNBREAKABLE);
Don't make my cool orange glass glowing, help?

quaint mantle
#

Hello, I don't know a thing about nms. And I want to support multiple versions of my plugin. Do you have any tutorials for anyone who hasn't done nms at all?

lost matrix
paper viper
#

good luck supporting other plugins

#

(:

green prism
#

Yea but my glowing cool orange glass? 😭

unreal quartz
#

did you actually enchant it?

green prism
unreal quartz
#

well then

#

that might just be your problem

unreal quartz
#

yeah.. you need to actually enchant it with something for it to glow

#

the item flag simply hides the fact that it is enchanted in the lore

solemn shoal
#

and if possible, more ticks in general

green prism
young knoll
#

gamerule randomTickSpeed?

solemn shoal
#

from code i meant

#

not a persistent thing

young knoll
#

I mean you can set the randomTickSpeed from code

solemn shoal
#

basically what im trying to achieve is speeding up the game whilst players sleep

young knoll
#

So set the tick speed higher for a bit when they sleep

green prism
young knoll
#

Just add any enchant

quiet ice
#

Force the enchantment?

green prism
quiet ice
#

Use your IDE

#

It should be called "applyUnsafeEnchantment" or similar

lost matrix
# solemn shoal from code i meant

I looked a bit into the MinecraftServer class and this is worth a try:

  public void forceTickNow() throws ReflectiveOperationException {
    final MinecraftServer server = MinecraftServer.getServer();

    final Field forceTicks = MinecraftServer.class.getDeclaredField("forceTicks");
    forceTicks.setAccessible(true);
    forceTicks.setBoolean(server, true);
    
    final Field nextTick = MinecraftServer.class.getDeclaredField("nextTick");
    nextTick.setAccessible(true);
    nextTick.setLong(server, SystemUtils.getMonotonicMillis());
  }
green prism
young knoll
#

You’ll still have to do some other stuff to speed everything up

#

Such as furnaces

green prism
quiet ice
#

Ugh

#

?jd

green prism
# quiet ice ?jd

I think the problem is here:
orangeglass.addUnsafeEnchantment(Enchantment.VANISHING_CURSE, 1);
orangeglassmeta.addItemFlags(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_UNBREAKABLE);

On the flag

quiet ice
#

Also, did you even set the itemmeta?

#

And you should also no change the enchantment via non-itemmeta ways in between obtaining the itemmeta and setting it on an itemstack, as otherwise it will get overridden

green prism
quiet ice
#

see, this is you issue

green prism
young knoll
#

You should use the item meta enchanting methods

#

Not the itemstack ones

quiet ice
#

probably since you are already manipulating item meta

green prism
# quiet ice probably since you are already manipulating item meta

ItemStack orangeglass = new ItemStack(Material.ORANGE_STAINED_GLASS_PANE);
ItemMeta orangeglassmeta = orangeglass.getItemMeta();
orangeglass.addUnsafeEnchantment(Enchantment.VANISHING_CURSE, 1);
orangeglass.addItemFlags(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_UNBREAKABLE);
orangeglassmeta.setDisplayName(ChatColor.GRAY + "");
orangeglass.setItemMeta(orangeglassmeta);

This doesn't work..

quiet ice
#

WOW did you even read my comment?

young knoll
#

You are still using the itemstack methods

paper viper
#

kekkekekekekkkk

quiet ice
#

Issue is there is no force enchantment method for itemmeta

#

There is a ignore levelcap parameter though, but I do not know if it is doing what it should

#

So better be safe than sorry

green prism
quiet ice
#

Stop being an idiot ffs

#

And you should also no change the enchantment via non-itemmeta ways in between obtaining the itemmeta and setting it on an itemstack, as otherwise it will get overridden

#

Shut mr automod

young knoll
#

You shouldn’t do it at all if you are already editing the meta

quiet ice
#

^

green prism
quiet ice
#

xy cvdfhmkljrzäfs vjvxcdizk

#

Ight, discord is bad for my mental health, if anyone needs me, I'll be at IRC

last lintel
#

Hello again

last lintel
#

is there an easy way to have different inventories in each world?

#

for example when im in a hub i will have a different inv than when im in survival world

blazing grove
last lintel
#

a what?

solemn shoal
#

nvm im dumb, didnt start my timer

blazing grove
lost matrix
# solemn shoal doesnt seem to work?

Im currently in a deep dive on the search of the class that extends MinecraftServer.
My first hint was DedicatedMinecraftServer.class but i cant find it. I might need to follow the breadcrumbs through the manifest file and the whole bootstrapping to find out what
single method invokes the actual tick.

last lintel
blazing grove
#

Hashmap in a hashmap

#

HashMap<UUID, HashMap<Integer, Inventory> data = new HashMap<UUID, HashMap<Integer, Inventory>();

solemn shoal
#

note to self: dont invoke 5 ticks at once

blazing grove
#

I think this should work

solemn shoal
blazing grove
lost matrix
# solemn shoal

As i told you: You will break absolutely everything. Minecraft is hard wired on this 20 TPS constant.

solemn shoal
#

no i was trying to run infinite ticks lol

lost matrix
solemn shoal
#

also minecraft catches up when it has a lag spike

#

sometimes peaking up to hundreds of tps

humble stirrup
solemn shoal
#

yes

#

fork heaven, i know

humble stirrup
#

yatopia is fork hell

solemn shoal
#

same thing

#

i have yet to see plugins break because of it

humble stirrup
#

i've heard stories

solemn shoal
#

works fine with this setup for me

humble stirrup
#

enjoy when your world gets eaten for breakfast

solemn shoal
#

havent had that issue

#

only when the first 1.16 builds came out

humble stirrup
#

it's literally just a compilation of everyone else's patches

solemn shoal
#

well yes

lost matrix
# solemn shoal same thing

Btw this is the actual method that gets called by the minecraft scheduler.

  public void forceTickNow() throws ReflectiveOperationException {
    final MinecraftServer server = MinecraftServer.getServer();
    final Method tickMethod = MinecraftServer.class.getDeclaredMethod("b", BooleanSupplier.class);
    tickMethod.setAccessible(true);
    final BooleanSupplier someBool = () -> true;
    tickMethod.invoke(server, someBool);
  }
solemn shoal
#

isnt b already public?

lost matrix
#

Its protected i think

solemn shoal
wise mesa
#

what's the "good" way to get the main instance of a plugin

#

instead of using singletons

#

I want to make my main instance accesable

lost matrix
lost matrix
cursive glen
#

Heyo!

#

Just wondering how I can add stuff to my config.yml from another class that isn't my main.

blazing grove
#

Use an instance

#

Or you can use YamlConfiguration.loadConfiguration i think

cursive glen
#

hm

#

I'll try to figure it oyut

#

out**

blazing grove
#

if (configFile == null) {
configFile=new File(Main.instance.getDataFolder(), "config.yml");
}
configuration=YamlConfiguration.loadConfiguration(configFile);

#

I use this

quaint mantle
#

im a bit stuck on this. i want to list all online players on index but i dont have a clue on how i can do this

wise mesa
#

I don't really want to use a singleton

solemn shoal
#

imma try your code now

wise mesa
#

I guess it doesn't matter too much

lost matrix
wise mesa
#

makes sense

#

thanks

solemn shoal
#

hey smile, your code doesnt seem to work either

#

nvm

#

it isnt reflected in the server TPS tho

lost matrix
minor garnet
#

is there a decent way to make a particle trail just using the player's direction?

wise mesa
#

I'm trying to learn all the test driven development-type stuff

#

and good oop and all that

lost matrix
# solemn shoal it isnt reflected in the server TPS tho

Btw this is hilarious:

  @Override
  public void onEnable() {
    Bukkit.getScheduler().runTaskTimer(this, () -> {
      try {
        SpigotCore.forceTickNow();
      } catch (final ReflectiveOperationException e) {
        e.printStackTrace();
      }
    }, 1, 1);
    Bukkit.getPluginManager().registerEvents(this, this);
  }

  public static void forceTickNow() throws ReflectiveOperationException {
    final MinecraftServer server = MinecraftServer.getServer();
    final Method tickMethod = MinecraftServer.class.getDeclaredMethod("b", BooleanSupplier.class);
    tickMethod.setAccessible(true);
    final BooleanSupplier someBool = () -> true;
    tickMethod.invoke(server, someBool);
  }

Everything just runs twice as fast/often.

But the client gets out of sync very often.

solemn shoal
#

i mean im surprised the server only reports 20tps regardless of running faster, considering if its catching up due to lag, it works fine

eternal oxide
solemn shoal
#

lol @lost matrix

#

i was about to point that out

#

practically the same code

minor garnet
#

trail for a place

lost matrix
solemn shoal
#

i mean if the server had a lag spike, and it catches up, it does go above 20

eternal oxide
#

@minor garnet yes it fairly easy but you need to explain your end goal better so we don;t waste time on things you don't need

wise mesa
#

maybe you should consider caching the method in a static variable or something

lost matrix
wise mesa
#

ah ok makes sense

minor garnet
#

I just need to do a particle trail when you right-click in the direction from which you aimed

cursive glen
#

lol im so big brain

#

I was adding something to my config.yml and I was wondering why it wasn't showing up

eternal oxide
#

@minor garnet ok thats easy.

cursive glen
#

then I realized I forgot to save lol 😂

lost matrix
minor garnet
#

that ?

lost matrix
eternal oxide
#

@minor garnet When you click you just need to get the players location. then loop however may times you want to place a particle java Location loc = player.getLocation(); Vector direction = loc.getDirection(); Location particle; for(int x... particle = loc.clone().add(direction.clone().multiply(x)); loc.getWorld().spawn...

solemn shoal
#

@lost matrix time to call that code from a timer lol

lost matrix
solemn shoal
#

how would i make it run faster tho

#

coz now we've got twice the speed

lost matrix
solemn shoal
#

what, just fork spigot?

lost matrix
cinder thistle
#

Generics pognt:

I currently have OxideDAO<T> defined. I have a map of it that looks like this: Map<String, OxideDAO<?>>. It is defined in another class. I am trying to use this to get a DAO from the map: OxideDAO<Ban> testDAO = (OxideDAO<Ban>) databaseHandler.getDaos().get("ban"); However, there's all kinds of generics issues with that. IntelliJ wants me to generify the class, but when I try to, it does nothing. I'd also prefer a way that doesn't require me to cast. The class Ban doesn't extend anything; it's a morphia (mongo) object.

What should I do?

#

Side note: getDaos is generated by lombok and I cba to rename it yet

lost matrix
minor garnet
#

what is the maximum speed of a projectile for it not to be going in random relations on the player's client?

eternal oxide
#

random relations?

cinder thistle
lost matrix
cinder thistle
#

ah, I see.

minor garnet
eternal oxide
#

velocity is a Vector so there should never be a random direction

cinder thistle
#

Oh nvm I get it

lost matrix
solemn shoal
#

nvm you can spam the method

cinder thistle
#

poggers OxideDAO<Ban> testDAO = databaseHandler.getDAO("ban", Ban.class);

#

poggers is my thing right now

#

it works

civic apex
#

how do I check the first collision with a block from the player's direction? in a max of 8 blocks
I want to teleport the player to the location that is 8 blocks in the direction they are looking at, but stop them if there is a block in between

Location destination = p.getLocation().add(p.getLocation().getDirection().multiply(8));
p.teleport(destination);

that's the code I have right now (no checks for collisions)

lost matrix
#

Ray trace for blocks or use a BlockIterator

civic apex
#

how do I use raytracing?

civic apex
#

but I need to get the collision location as well

eternal oxide
#

if there is a collision, you get a RayTraceResult

civic apex
#

oh

#

k

#

on the first one?

eternal oxide
#

yes

#

read the javadoc, it gives you everything

lost matrix
# civic apex how do I use raytracing?
  public Vector traceOrMax(final Location start, final Vector direction, final double length) {
    final RayTraceResult result = start.getWorld().rayTraceBlocks(start, direction, length);
    if (result == null) {
      return direction.multiply(length);
    }
    final Block hitBlock = result.getHitBlock();
    if (hitBlock == null) {
      return direction.multiply(length);
    }
    final Vector hitPosition = result.getHitPosition();
    return hitPosition.subtract(start.toVector());
  }

This will return the max length vector or the vector at which the first Block
was hit if present.

civic apex
#

ok thanks

solemn shoal
#

question, how can i unload a plugin through code?

#

say i want to disable & unload a plugin called SleepFix

lost matrix
#

You can try:
Bukkit.getPluginManager()#disablePlugin(JavaPlugin);

solemn shoal
#

which overload?

#

(Plugin) or (Plugin, boolean)

lost matrix
#

Spigot only has one method.

civic apex
#

wait my IDE says world doesn't have the method rayTraceBlocks()

lost matrix
civic apex
#

can I use newer spigot/bukkit api methods for a legacy server?

#

like 1.16 api for 1.8 server

lost matrix
#

lol

civic apex
#

no right?

eternal oxide
#

update to 1.16 and use a plugin to provide 1.8 combat

lost matrix
#

No. The 1.8 server just misses a ton of new API features. Its old and unsupported for a reason.

solemn shoal
#

i guess its a paper thing then

green prism
#

Do you know an easy-method for create an "Animate GUI"?

lost matrix
daring sierra
#

i read this is "anime tea'd goo why"

green prism
lost matrix
#

Yes. I would create a single scheduled runnable that contains some collection of tickable inventories of which each is a state machine that can be progressed by ticking it.

#

Then upon opening the inventory i would add it (or better its wrapper) to the runnable and remove it again when the player closes the inventory.

solemn shoal
#

ok cool server

outer crane
#

very cool server

#

also is that.... cmd.exe?
runs

solemn shoal
#

yes it is

#

its my plugin test server so it doesnt matter

#

anyways

#

dunno how i didnt notice

green prism
civic apex
#

and btw if i compile for newer versions

#

would I have to add api-version?

eternal oxide
#

1.8 is over 5 years old and no longer supported

lost matrix
civic apex
civic apex
solemn shoal
#

then write it for 1.8

eternal oxide
#

as 7smile7 said, unless you have hundreds of concurrent users you'll never notice.

solemn shoal
#

^ this too

#

like.. i dont notice at all lol

civic apex
#

might also have to do with me running the server on a rpi

#

hmm

solemn shoal
#

youre already going for low spec hardware to begin with

lost matrix
solemn shoal
#

1.16 with 1 gig

civic apex
#

i have a 4gb rpi

#

and run a 1.16 smp in paper with preloaded chunks and the server goes to 8tps with 3 players

#

:c

lost matrix
#

You probably installed a bunch of trash plugins.

#

And didnt configure the server for the load.

civic apex
#

??

#

i only use plugins to load chunks, tp through worlds and my custom coded ones

#

none of them should really lag the server that much

#

i also turned down the chunk distance to like 8

lost matrix
#

Run timings v2 (to track down bottlenecks)
Also use a high Java version and the G1GC

quaint mantle
#

@civic apex use Spark and run it for a bit to get some info about your server and what’s happening

#

you’ll get much more in-depth info about the root of the issue than regular timings

civic apex
#

my wifi went out

#

well i was using java 8

#

that might have smth to do with it

quaint mantle
#

nah 8 is fine

solemn shoal
#

is there a way i can display mob health bars without overriding their names?

fervent cove
#

can some1 help me

#

bb and bp should final or something like this idk but where i must change this

sturdy patrol
#

@solemn shoal You could probably use packets. That way, the server will not have to rename mobs, but the clients will think the mobs are named

solemn shoal
#

hm its not like i can do a scoreboard belowName kinda thing?

opal juniper
#

e.g. final Player bp;

civic apex
#

does spigot fork craftbukkit?

eternal oxide
#

Spigot builds CraftBukkit

civic apex
#

how can I import CraftWorld?

eternal oxide
#

more precisely BuildTools builds Spigot and includes CraftBukkit.

eternal oxide
#

using Maven?

civic apex
#

no

#

with import

eternal oxide
#

if you are importing a spigot jar then CraftWorld is in there

civic apex
#

well

#

wait isnt craftworld from nms?

eternal oxide
#

as I said above.

civic apex
#

but is it from nms or bukkit/spigot?

eternal oxide
#

Its bukkit

#

nms is World

civic apex
#

and how do I import it then?

eternal oxide
#

Spigot jar has them all

civic apex
#

because (CraftWorld) world gives me an error

eternal oxide
#

show what you are trying to do

civic apex
#
CraftWolrd cw = (CraftWorld) e.getPlayer().getLocation().getWorld();
eternal oxide
#

I hope thats a typo

civic apex
#

it was

eternal oxide
#

then that code is correct

civic apex
#

bc i did it correctly before and still error

#

well its red

eternal oxide
#

are you tryign to get the NMS world object?

civic apex
#

maybe

#

im trying to raytraceblocks in 1.8

eternal oxide
#

oh

#

yeah, good luck with that

solemn shoal
#

hm, how can i fix a "NoClassDefFound" error?

civic apex
#

:c

solemn shoal
#

my class exists yet the server throws a tantrum over it

eternal oxide
#

No class found = using a lib thats not on yrou server at runtime

solemn shoal
#

its another class in my plugin

civic apex
solemn shoal
#
[20:33:32 ERROR]: Could not pass event BlockRedstoneEvent to EssentialTools v1.0
[20:33:32 ERROR]: Suspected Plugins:
[20:33:32 ERROR]:       EssentialTools{enabled,ver=1.0,path=plugins\EssentialTools.jar}
[20:33:32 ERROR]: Exception details below:
java.lang.NoClassDefFoundError: net/thearcanebrony/essentialtools/mechanics/RedstoneEventTracking
        at net.thearcanebrony.essentialtools.events.ETBlockRedstoneEvent.RedstoneEvent(ETBlockRedstoneEvent.java:14) ~[?:?]```
civic apex
solemn shoal
eternal oxide
#

ETBlockRedstoneEvent.java:14

solemn shoal
#
package net.thearcanebrony.essentialtools.events;

import net.thearcanebrony.essentialtools.RuntimeStore;
import net.thearcanebrony.essentialtools.mechanics.RedstoneEventTracking;
import net.thearcanebrony.essentialtools.wrappers.ETEventHandler;
import org.bukkit.Chunk;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockRedstoneEvent;

public class ETBlockRedstoneEvent extends ETEventHandler {
    @EventHandler
    public void RedstoneEvent(BlockRedstoneEvent e) {
        Chunk a = e.getBlock().getLocation().getChunk();
        RuntimeStore.RedstoneEvents.get(RedstoneEventTracking.CurrentTick).add(new Integer[]{a.getX(), a.getZ()});
    }
}```
#

line 14 is RuntimeStore... (2 lines from end)

eternal oxide
#

That error you posted looks odd. Suspected plugins?

solemn shoal
#

suspected plugins..

#

only one listed is mine

#

(all the code is in the same plugin)

#

its definately there in the jar..

eternal oxide
#

throw your RedstoneEventTracking.java in here

solemn shoal
#

one sec gotta figure out whats eating my cpu

eternal oxide
#

just drag/drop it will auto format

civic apex
#

wait my org.bukkit.craftbukkit only has Main as a class

weary geyser
#

Can you make a parent module depend on a child module? (Maven)

solemn shoal
#

drag/drop what?

eternal oxide
#

nm I see you posted source

solemn shoal
#

yeah

#

hold up lemme push

#

okay pushed

#

its all up to date with my local now

civic apex
weary geyser
#

did you import bukkit

civic apex
#

i imported spigot

weary geyser
#

you need bukkit

civic apex
#

both imported?

civic apex
solemn shoal
#

im compiling against a yatopia jar but youre on 1.8 so i cant help you there

weary geyser
civic apex
civic apex
#

ant? i dont actually know

weary geyser
#

Use a framework

civic apex
#

just use import

wicked shale
weary geyser
#

That's way better

weary geyser
#

meant child module

#

typo

wicked shale
#

Yes I think

weary geyser
#

How would you do it?

wicked shale
#

Well it's a bit confusing

weary geyser
#
        <dependency>
            <groupId>me.zoibox.core</groupId>
            <artifactId>LucentAPI</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>``` Because that didn't work
wicked shale
#

what was the error?

weary geyser
#

Nothing

#

It just didn't work

#

None of the classes showed up

wicked shale
#

like the imports didn't work?

#

yeah

weary geyser
#

Yk a fix?

wicked shale
#

its impossible to know without some context or smthing

weary geyser
#

What do you want

wicked shale
#

could you show me your full pom

weary geyser
#

Which class

#

*module

wicked shale
#

the snippet you posted

#

that one

weary geyser
wicked shale
#

Yeah i'm not sure hm

lost matrix
solemn shoal
#

i compile against a paperclip cached jar

lost matrix
solemn shoal
#

then everything is available to me

#

i dont use maven

lost matrix
solemn shoal
#

i started in eclipse

eternal oxide
#

This support is for Spigot only. Replace your jar with Spigot and try. If it doesn't work come back for help

solemn shoal
#

never learned how to set up maven etc

lost matrix
solemn shoal
#

so uh, raw eclipse + ant tasks

#

@eternal oxide who is that for?

weary geyser
lost matrix
wicked shale
#

I was thinking of something different. Like we could have a completely separate project with a parent which its dependencies having one of the childs of another project as a dependency

solemn shoal
#

regardless @eternal oxide found any reason why my class wouldnt be found?

wicked shale
#

please don't use Ant

#

lol

solemn shoal
#

idk anything outside of ant lol

#

i'd be using gradle but idk how to set it up

#

regardless, it works fine for my usage

lost matrix
solemn shoal
#

i had a dependency ages ago

#

i just included its compiled files in my jar

#

also i currently have a dependency on Vault (softdepend)

#

(no im not compiling against 1.15)

#

just cba to rename that module

lost matrix
#

And then you see some proper java libraries you would like to use and have to tinker with maven commands to get an actual jar you can include.
And if one of the transitive dependencies changes you have no way of automatically detecting and updating that. ^^ But you will eventually encounter those problems.

solemn shoal
#

i mean, aside vault and a server jar i have no dependencies

#

wait let me try cleaning my build dir lol

#

or is that not a thing you can do in intellij?

#

that fixed it..

dense eagle
#

What does EntityDamageEvent.DamageCause.CUSTOM does and how could I use it?

solemn shoal
#

its just an explanation of how an entity was damaged for devs

humble stirrup
#

iirc it's only used when specified manually by a plugin

lost matrix
dense eagle
#

Does it let me display custom death causes?

humble stirrup
#

no

dense eagle
#

How could I override death messages only on some ocassions?

humble stirrup
#

EntityDeathEvent#setDeathMessage(String)

lost matrix
dense eagle
#

Ok, thanks!

eternal oxide
solemn shoal
#

404

eternal oxide
#

silly links

#

it was just a fix for offline uuids for pseudo players being duplicated in CraftBukkit

#

but it was from 2014

solemn shoal
#

oh lol

civic apex
#

how do I get an array of blocks that go on a straight line between 2 positions, or one position and a vector?

quaint mantle
#

loop getRelative for X distance

#

How to make a delay in event? Like PlayerMoveEvent player moves send message 2 seconds send message. For not spamming.

lost matrix
lost matrix
quaint mantle
#

Thanks

lost matrix
# civic apex how do I get an array of blocks that go on a straight line between 2 positions, ...

Something like this should work:

  public List<Block> getBlocksInBetween(final Location from, final Location to) {
    Preconditions.checkArgument(from.getWorld() != null && from.getWorld().equals(to.getWorld()));
    final World world = from.getWorld();
    final Vector start = from.toVector();
    final Vector direction = to.toVector().subtract(from.toVector());
    final int distance = (int) Math.floor(direction.length());
    final double yOffset = 0;
    final BlockIterator blockIterator = new BlockIterator(world, start, direction, yOffset, distance);
    final ArrayList<Block> blockList = new ArrayList<>();
    blockIterator.forEachRemaining(blockList::add);
    return blockList;
  }
obtuse basin
#

any idea why this doesnt work? ```
class simplecmd: CommandExecutor {

override fun onCommand(
    sender: CommandSender?,
    command: Command?,
    label: String?,
    args: Array<out String>?,
): Boolean {
    val player: OfflinePlayer? = null
    val worldname: String = player?.getUniqueId().toString()
    if(Bukkit.getWorld(worldname) != null) {

Bukkit.createWorld(WorldCreator(worldname).type(WorldType.valueOf("DEFAULT")))
return true
} else {
return true
}
}
}```

#

it doesn't gives any error or smth

civic apex
#

that isn't java right?

lost matrix
obtuse basin
civic apex
#

oh ok

civic apex
#

thought that was only used for android dev mb

lost matrix
#

Btw this can be scrapped to just return true at the end:

            return true
        } else {
           return true
        }
quaint mantle
#

Hey someone have an idea how to cancel a block place in radius 3 arond block of sandstone

solemn shoal
#

@civic apex java is used for android dev too

lost matrix
quaint mantle
#

every

obtuse basin
lost matrix
# quaint mantle every

Could be expensive... The only thing i could think of is iterating over every nearby block.

solemn shoal
#

i dont like kotlin's syntax, but to each their own

#

also afaik kotlin and java compile to the same bytecode regardless

lost matrix
# quaint mantle every

So

  public boolean isNearMaterial(final Block block, final int checkRadius, Material material) {
    for (int x = -checkRadius; x < checkRadius; x++) {
      for (int y = -checkRadius; y < checkRadius; y++) {
        for (int z = -checkRadius; z < checkRadius; z++) {
          if (block.getRelative(x, y, z).getType() == material) {
            return true;
          }
        }
      }
    }
    return false;
  }

I have some things in mind that could be done for optimizing this but they are really labour intensive.

green prism
#

Guys, i've a problem, I need to make a region of the GUI clickable and i need to transfer item in it, but I can't move items from my main inventory, help?

I tried with a switch of all single slot

lost matrix
lost matrix
#

Atrocious.
If you want to determine if a slot is clickable then you can just use a Set<Integer> and add all non clickable slots in there. Then you simply call contains on that Set to check if the event should be cancelled or not.

green prism
#

I can't move from my main inv

#

I was using if, switch + default and so more..

lost matrix
#

Yes. Dont create fields but just have methods that take a Location and create an Entity at that location
public LivingEntity spawnSpecialMob(Location location) {

lost matrix
green prism
lost matrix
#

You should add this to some manager class.

lost matrix
#

Perfect

#

At the point you write the method you have no idea what Location you will get later on.
You just write the method and dont call it in your constructor. You call it every time when a mob should be spawned later on.

quaint mantle
green prism
lost matrix
lost matrix
#

What do you mean by that? Do you mean what you should put there as method parameter? As method body? As return value or type?

green prism
#

The problem is only this: "I can't move from my main inventory"

lost matrix
green prism
lost matrix
green prism
quaint mantle
#

i would like to get a radius around player and delete all sandstone blocks

#
int raduis = 2;
                Block middle = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
                for (int x = raduis; x >= -raduis; x--) {
                    for (int y = raduis; y >= -raduis; y--) {
                        for (int z = raduis; z >= -raduis; z--) {
                            if (middle.getRelative(x, y, z).getType() == Material.SANDSTONE) {
                 
                            }
                        }
                    }
                }```
#

i don't know if it's good ?

lost matrix
quaint mantle
#

idu

lost matrix
#

Then you need to stop with Spigot and give yourself some days to learn the very basics of Java.

#

You spawn the mob inside the method body, modify it then return it.

#

You can get the World instance from the Location variable.

#

Spawning the mob gives you an instance of Entity (Wither, Zombie, Skeleton or whatever)
Just return that

quaint mantle
#
int radius = 5;
final Block block = event.getBlock(); //placed block
for (int x = -(radius); x <= radius; x ++)
{
  for (int y = -(radius); y <= radius; y ++)
  {
    for (int z = -(radius); z <= radius; z ++)
    {
      if (block.getRelative(x,y,z).getType() == Material.OBSIDIAN)
      {
          block.getBlock().setType(Material.AIR);
       }
     }
   }

}
#

it will work ?

lost matrix
#

This does not return the "mobname"

#

But it is correct.

lost matrix
#

Its a variable...

#

Not even close...

#

Im not trying to be a d**k but you need to learn at least the very basics of the programming language before jumping into writing plugins for another application that was written in that language.
And you did clearly not take the time to do that...

#

This is an example of how you would use a static spawn method from your MobManager class
to spawn some mob each time a certain Material is broken:

  @EventHandler
  public void onBreak(BlockBreakEvent event) {
    // Get the block from the event
    Block block = event.getBlock();
    
    // Check if the block is of type OBSIDIAN
    // If its not then we do nothing (We just return)
    if (block.getType() != Material.OBSIDIAN) {
      return;
    }
    
    // Get the location of the broken block
    Location blockLocation = block.getLocation();
    
    // Spawn a mob at that location by using the MobManager
    MobManager.spawnObsidianZombie(blockLocation);
  }

But i strongly advice against using the static keyword until you understood it completely.
99% of Java can and should be done without using statics.

opal juniper
#

@lost matrix just out of interest how long have you been doing Java

lost matrix
opal juniper
#

Oh wow, so not that long

lost matrix
#

Or winter 2018? Thats more probable. So 2 - 2.5 years i suppose

opal juniper
#

Dang ur good

lost matrix
#

Thanks 😄 i just got a passion for programming. Ive actually started because of Minecraft.

ancient plank
#

It's very satisfying 👍

lost matrix
quaint mantle
#

How may I send action bar messages in 1.8.8?

lost matrix
quaint mantle
lost matrix
opal juniper
quaint mantle
#

yeah I know, I did but nothing I find on the forums works

lost matrix
opal juniper
quaint mantle