#help-development

1 messages · Page 1663 of 1

opal juniper
#

no

gaunt saffron
#

it's been 8 years since i touched java, i forgot everything

quaint mantle
#

No!

#

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

opal juniper
#

PluginManager#registerEvents(new MyEvents(this), this)

#

what he said

gaunt saffron
#

i dont get this line at all, but i guess i dont need to

opal juniper
#

Well, its the same as before

#

however you are just passing this thru the constructor

#

which refers to the current class

gaunt saffron
#
The constructor MyEvents(App) is undefinedJava(134217858)
com.thechemicalworkshop.MyEvents```

import?
opal juniper
#

did you copy the code i did

gaunt saffron
#

nope, his

opal juniper
#

well

#

you need this

#

in your MyEvents class

hasty prawn
#

You should also make sure that the right App is imported too actually.

opal juniper
#

no...

#

cause we aren't gonna use it

#

just use JavaPlugin

#

cause it extends it

gaunt saffron
#

okay, if i put it in 1 file

#

i dont have to worry reight?

opal juniper
#

unless you need instance fields there is no need Dessie

gaunt saffron
#

im confused aswell.. should have used git.. whoopys

hasty prawn
# opal juniper no...

If he's importing a completely different App class, that doesn't extend JavaPlugin, it would whine about it

quaint mantle
#

Undo that (for real)

gaunt saffron
#
package com.thechemicalworkshop;

import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.entity.HumanEntity;
import org.bukkit.GameMode;
import org.bukkit.Bukkit;

public class MyEvents implements Listener {
    @EventHandler
    public void onPlayerDeath(PlayerDeathEvent e) {
        Player player = e.getEntity();
        // System.out.println(player.getName());
        int delay = 1;
        Bukkit.getScheduler().runTaskLater(this.plugin, () -> {

            player.setGameMode(GameMode.SPECTATOR);
            player.sendMessage(
                    ChatColor.RED + "" + ChatColor.BOLD + "" + "aghh you died !\n" +
                    ChatColor.RED + "" + ChatColor.BOLD + "" + "you can spectate others or use " +
                    ChatColor.GREEN + "" + ChatColor.BOLD + "" + "/lobby " + ChatColor.RED + "" +
                    ChatColor.BOLD + "" + "to go back");
            player.spigot().respawn();
            // Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say hi");
        }, delay);
    }
}

myevent.java

opal juniper
#

so copy this

#

into that class

hasty prawn
#

^ You need the constructor

gaunt saffron
#

top or bottom?

opal juniper
#

top

#

doesn't matter

quaint mantle
#

And then you should be Set to Go hipefull

opal juniper
#

but is a good practice

quaint mantle
#

Convention is constructor in top, but doesnt matter

unreal quartz
#

convention is to write whole class in 1 line

quaint mantle
#

(after the class ClasName { )
Tjough

gaunt saffron
#

okay lemme try to compile..

#
[23:45:09 ERROR]: Error occurred while enabling BlankPlugin v0.1 (Is it up to date?)
java.lang.Error: Unresolved compilation problem:
        The constructor MyEvents(App) is undefined

        at com.thechemicalworkshop.App.onEnable(App.java:9) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.17.1.jar:git-Paper-85]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-85]

i bet i messed smth up, again

#

i think i'll do everything in 1 file

opal juniper
#

NO

#

DONT

#

PLEASE

gaunt saffron
#

why?

opal juniper
#

its leads to horrible unmaintainable code

gaunt saffron
#

well i'm done if i get this working

quaint mantle
#

Because it's better If you learn from mistakes

opal juniper
#

?paste your events and main class

undone axleBOT
gaunt saffron
#

for now i need like 5 basic pkugins

gaunt saffron
opal juniper
#

?

#

wdym

gaunt saffron
#

my antivvirus goes nuts

#

lkemme find otrher bin

opal juniper
#

oh well just use pastebin ig

gaunt saffron
hasty prawn
#

Too high

#

Has to be in the class still

gaunt saffron
#

i did few hours of java dev for android like a year ago

and i did learn java like 8 years ago...

#
package com.thechemicalworkshop;

import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.entity.HumanEntity;
import org.bukkit.GameMode;
import org.bukkit.Bukkit;

public class MyEvents implements Listener {

    private JavaPlugin plugin;

    public MyEvents(JavaPlugin plugin) {
        this.plugin = plugin;
    }

    @EventHandler
    public void onPlayerDeath(PlayerDeathEvent e) {
        Player player = e.getEntity();
        // System.out.println(player.getName());
        int delay = 1;
        Bukkit.getScheduler().runTaskLater(this.plugin, () -> {

            player.setGameMode(GameMode.SPECTATOR);
            player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "" + "aghh you died !\n" + ChatColor.RED + ""
                    + ChatColor.BOLD + "" + "you can spectate others or use " + ChatColor.GREEN + "" + ChatColor.BOLD
                    + "" + "/lobby " + ChatColor.RED + "" + ChatColor.BOLD + "" + "to go back");
            player.spigot().respawn();
            // Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say hi");
        }, delay);
    }
}

compiling

#

i wish the compiler would tell me

prime birch
#

Anyone know
My friend can't get unbanned
I'm on the proxy
And i unban him
He won't get unbanned

unreal quartz
prime birch
#

Ooops

gaunt saffron
#
[23:50:51 ERROR]: Error occurred while enabling BlankPlugin v0.1 (Is it up to date?)
java.lang.Error: Unresolved compilation problem:
        The constructor MyEvents(JavaPlugin) refers to the missing type JavaPlugin

        at com.thechemicalworkshop.App.onEnable(App.java:9) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.17.1.jar:git-Paper-85]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-85]

i feel like 1 file...

#

i thought it's all easy modular

unreal quartz
#

are you not using an IDE

gaunt saffron
#

well my "IDE" gives me tons of errors..

unreal quartz
#

mayb eyou should resolve them then

gaunt saffron
#

even on code you guys gave me, there are errors on imports

unreal quartz
#

do you even have the jdk

gaunt saffron
#

The import org.bukkit cannot be resolvedJava(268435846)
import org.bukkit.event.Listener;

#

yeah

unreal quartz
#

then you don't have bukkit as a dependency

gaunt saffron
#

io have spigot

#

so can i just replace all functions wiith spigot? since im using spigot anyways

#

also spigot docs

unreal quartz
#

you do not have spigot added as a dependency which is why your IDE is screaming at you

gaunt saffron
#
    <dependency>
        <groupId>org.spigotmc</groupId>
        <artifactId>spigot-api</artifactId>
        <version>LATEST</version><!--change this value depending on the version or use LATEST-->
        <type>jar</type>
        <scope>provided</scope>
    </dependency>```
unreal quartz
#

make sure you have the repository added, try specifying a version, make sure your IDE is actually using maven

gaunt saffron
#

it's maven

#

it says so

gaunt saffron
#

plugin.yml
Incorrect type. Expected "string". for version...

#

even tho it works fine ,and the tutorial on spigot says to use this

unreal quartz
#

vscode is very ehhhhhhh when it comes to java

gaunt saffron
#

well im not gonna switch for 2 reasons
using vscode for too long
dont have space

opal juniper
#

vscode is good for some langs

#

but as bishop said

#

not really for java

gaunt saffron
#

well, if i switch to another IDE, my efficiency will go way down

#

plus, setting up vscode is easy, eclipse is massive pain

#

well, years ago it was at least

lost matrix
opal juniper
#

use intellij

#

trust

#

it is easy

gaunt saffron
#

how big?

lost matrix
opal juniper
#

like less than a gig

gaunt saffron
opal juniper
gaunt saffron
#

yeah nope, can't afford that 😂

#

200 would be okay

wary harness
#

I got weird problem with yml file

#
## Drop chances per block!
## Chance: Can be set from 0.01 to max 100 (100% or above will give sure drop).
## NumTokens: Number of Tokens given to the player upon mining a block.
## Per World chances will override Global chances!
## Material types 1.8 https://helpch.at/docs/1.8/org/bukkit/Material.html
## Material types Spigot lastest https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
Options:
#Token Drop messages
  Message:
    Enabled: true
    ##Type:  CHAT, ACTIONBAR, TITLE, SUBTITLE
    Type: ACTIONBAR
##Timed message to display how many tokens player earned in last (60) sec
 TimedMessage:
  Enabled: false
  ##Type:  CHAT, ACTIONBAR, TITLE, SUBTITLE
  Type: CHAT
  ##Delay is in seconds
  Delay: 60
## Drop tokens to the floor as withdraw item
 FloorDrop:
  Enabled: false
  ## This will be signature on item
  Signature: "&7Block Drop"
##Disable drop is specific world for Global Drops
 NoDropWorlds:
   - world_the_end
DropChances:
  Global:
    IRON_ORE:
      Chance: 100
      NumTokens: 1
      CustomName: "&bIron Ore"
  Worlds:
    world:
      COAL_ORE:
        Chance: 50
        NumTokens: 3
      GOLD_ORE:
        Chance: 60
        NumTokens: 5
    world_nether:
      IRON_ORE:
        Chance: 40
        NumTokens: 80
      DIAMOND_ORE:
        Chance: 0.5
        NumTokens: 15
##Config version (PLEASE DO NOT EDIT)
ConfigVersion: 1.1```
hybrid spoke
#

?paste

undone axleBOT
hasty prawn
#

Needs 2

opal juniper
#

ur good

wary harness
#

still not working

opal juniper
#

lierally enough space

wary harness
#

@hasty prawn

gaunt saffron
hasty prawn
#

Does it say FloorDrop now instead

gaunt saffron
#

and i really wanna keep the bare minimum

lost matrix
#

Your Indentation is broken

hasty prawn
#

Most the indentation is broken

gaunt saffron
#

okay thanks for help, also rip, gotta go sleep

lost matrix
gaunt saffron
lost matrix
#

F

unreal quartz
#

how many slots do you have for such a small amount of disk space

gaunt saffron
gaunt saffron
#

oh

#

the on i'm on is a vm

unreal quartz
#

did you put 10gb ssds in each one or something

gaunt saffron
#

no i have 120gb ssd for coding, which is 65 alocated rest for backups

lost matrix
#

Lol ive just found a 1TB hard drive for 28 bucks. Storage is cheap nowadays...

gaunt saffron
#

as for oracle sotrage im limited to 50gb disk 🙄

gaunt saffron
unreal quartz
#

you have a very strange setup

gaunt saffron
unreal quartz
#

i have never been concerned about malware

opal juniper
#

is malware even an issue anymore

#

yeah xD

#

like

gaunt saffron
#

yes, i use ghidra 😂

opal juniper
#

just dont be a dumbass

#

oh

eternal oxide
#

Windoiws defender is all I have

opal juniper
#

^

unreal quartz
#

what are you installing which you need to be so paranoid over

opal juniper
#

same

unreal quartz
#

from what? intellij?

opal juniper
#

ghidra

gaunt saffron
#

no, whatever i find on itermet

opal juniper
#

to decompile ig

unreal quartz
#

everybody knows jetbrains are secretly infecting all out machines

gaunt saffron
#

then decompile with ghidra

unreal quartz
#

what sketchy shit are you finding then

opal juniper
#

java 😳

gaunt saffron
#

sometimtes it yeets the VM

opal juniper
lost matrix
#

Browsers are safe nowadays. If you dont go to www.flank-my-pc.net download the first catimages.png.exe and execute it you wont be in danger too much.

gaunt saffron
#

also i use VM's for privacy... when running long streams like 12+h i porefer not to show my stuff to everyone

gaunt saffron
unreal quartz
#

why

gaunt saffron
#

to download that skethy stuff, see if i can obfuscate it, figure out how it works

eternal oxide
lost matrix
unreal quartz
#

you are just causing yourself problems here really to the point where you can't even install IntelliJ

gaunt saffron
unreal quartz
#

then you are going to have years of issues using vscode

lost matrix
opal juniper
#

👀

opal juniper
gaunt saffron
lost matrix
opal juniper
#

xDDDDD

gaunt saffron
#

also VPS ssd space so expensive... jeez

#

anyways, thanks for help, i'll leave it either tomorrow or whenever, or i can remove the scheduler and respawn line... it will be a bug

like it tells you you died, do X to leave and then say you dies due to smth

opal juniper
lost matrix
opal juniper
#

google chrome with google does me fine

gaunt saffron
unreal quartz
#

whenever I used duckduckgo I would always end up using the !g bang to get google results instead

lost matrix
#

I also tried introducing the term duckduckgoing instead of googling but half the people never heard of that.

opal juniper
#

lmao

unreal quartz
#

the ddg results were never as good as google's no matter how much i wanted to use it

opal juniper
#

"lemme just duckduckgo it"

gaunt saffron
#

also a question, should i go into trouble of combining 2 simple plugins into 1?
let's say plugin A does spectator aafter death
and plugin B does custom join message

how much performance takes the loading plugin stuff use,. like the code that is in every plugin anyways?
like i need 6 plugins, and i could either add them to servers or allways add 1 plugin but percompile them toegther?
some servers need 1 plugin some need all 6

i hope you get my question

opal juniper
#

just make one

#

no real point

gaunt saffron
#

not yet, but they are simple

#

op on join
spectator on death

#

etc

paper viper
#

Just do 1

#

No point of multiple

gaunt saffron
#

is it worhth compiling like 20 pluging instead of 6?

paper viper
#

The performance difference is negligible

gaunt saffron
#

but thhen i want hundrets of servers

#

soo...

paper viper
#

Still small

gaunt saffron
#

oh

paper viper
#

Just do 1 plugin

#

Much easier

gaunt saffron
#

why easier?

paper viper
#

And also easier to handle in terms of development

#

Because you don’t have to back and forth

lost matrix
paper viper
#

And it’s annoying

gaunt saffron
#

well the problem would be

#

if i chance one plugin

#

i need to change all 20...

#

let's say i have
op on join
spectator on death

which equals
1 op on join
2 spectator on death
3 op on join and spectator on death

lost matrix
#

The only problem is version control. Because you team needs to understand how to work on a monolith

gaunt saffron
#

also git is private

#

so how i give him access is a zip

paper viper
#

You can still have private gits?

#

And also don’t use Zip to distribute files around.. please

#

Destroys the purpose of VCS

gaunt saffron
#

not sure, i dont use github

paper viper
#

GitHub has private repos

#

If you didn’t know

#

And they are free

gaunt saffron
#

i dont like github

paper viper
#

Okay then what do you use. GitLab?

gaunt saffron
#

just git

paper viper
#

At the end of the day it shouldn’t matter

gaunt saffron
#

on a remote server

paper viper
#

Ic

gaunt saffron
#

i could make him keys... but then yeah

#

i suck at that

#

i need about 6 simple plugins

#

and one big bungee plugin, which i might pay someone tbh

#

but the half a dozen or so i planned todo myself.,.. since it's really just "spectate on death"

#

i could use premade plugin and mod the config but then i feel like im wasting ressources... since i never wanted this plugin todo more

#

also i have stupid ideas like recompile paper and skip the saving step, to save time

#

so it restarts even faster...

dim bluff
#

Hey quick question… when I make a map in config.yml how do I put it in a HashMap to use in code?

lost matrix
quaint mantle
#

like key:value ?

dim bluff
#

items:
Steak : 10
Golden_Apple : 20

#

Etc

#

Idk if its even possible tbh

lost matrix
#

It sure is

#

Let me write an example

young knoll
#

getValues can get you a map

lost matrix
# dim bluff Idk if its even possible tbh

Example:

  private Map<String, Integer> loadSomeMap(final FileConfiguration configuration) {
    final Map<String, Integer> data = new HashMap<>();
    final ConfigurationSection section = configuration.getConfigurationSection("items");
    final Set<String> keys = section.getKeys(false);
    for (final String key : keys) {
      final int value = section.getInt(key);
      data.put(key, value);
    }
    return data;
  }
opal juniper
#

"loadSomeMap"

this is the type of method names that make it into my final code Sadge

lost matrix
#

lul

dim bluff
#

The config file?

opal juniper
#

myeah

#

loaded to a file configuration

calm whale
#

can someone please tell me how to prerender a map ? I would like to render a map at custom location with a red cross, I already have the map with location and the cross, but I don't know how to prerender it before I give it to the player, alternately if it is possible to render it as a mansion map it is good as well

#
MapView map = Bukkit.createMap(Bukkit.getWorld("world"));

map.setCenterX(0);
map.setCenterZ(0);
map.setTrackingPosition(true);
map.setUnlimitedTracking(true);
map.getRenderers().clear();
map.addRenderer(new MapRenderer() {
  @Override
  public void render(@NotNull MapView mapView, @NotNull MapCanvas mapCanvas, @NotNull Player player) {

    MapCursorCollection cursors = new MapCursorCollection();

    cursors.addCursor(new MapCursor((byte) 0, (byte) 0, (byte) 12, MapCursor.Type.RED_X, true));
    mapCanvas.setCursors(cursors);

  }
});

ItemStack m = new ItemStack(Material.FILLED_MAP);
MapMeta mm = (MapMeta) m.getItemMeta();
mm.setMapView(map);
mm.setMapId(map.getId());
m.setItemMeta(mm);```
#

I saw this piece of code on the forum but I don't know how to acces the WorldMap object

#
for (int x = 0; x < 128; ++x) {
  for (int y = 0; y < 128; ++y) {

    mapCanvas.setPixel(x, y, worldMap.colors[y * 128 + x]);
  }
}```
#

so you suggest me to put a random byte to check if the map get fully colored ?

#

I try

#

ok it works

#

but it is fine for painting

#

I want to render the actual region

#

how can I know the right color ?

#

it would be a performance's eater if I try to check each higher block of each x:z 🤔

echo basalt
#

I'm having the stupidest issue right now

#

It doesn't print the "Made util" line

#

Does anyone know wtf is going on?

calm whale
#

do you establish your sql connection ?

echo basalt
#

Yes

quaint mantle
echo basalt
quaint mantle
#

anyway, if anyone else knows why the falling block doesn't show it would help :)

echo basalt
#

I'm not that experienced in nms packets :(

#

I can do entity metadata in protocollib

calm whale
#

why do you use nms to spawn a falling block ?

echo basalt
calm whale
#

didn't fully read my bad

echo basalt
quaint mantle
#

because I need client sided falling blocks that don't interfere with other events in the server

echo basalt
#

huh it is actually

#

Weird

quaint mantle
#

anyway yes 7smile7 told me to use it and if you look into the P() it's a spawn out packet

echo basalt
#

Have you tried spawning the fallingsand manually?

quaint mantle
#

but even if I create the actual packet it doesn't work

#

yes

echo basalt
#

Weird

quaint mantle
#

you can see the entity particles landing

#

but never the falling block

echo basalt
#

Okay so it's a metadata issue

quaint mantle
#

idk maybe

echo basalt
#

idk how to do this with NMS but I know how to do it with protocollib

quaint mantle
#

you can link me up to the protocol lib lines I guess I will look into the protocol lib code

echo basalt
#

it's kinda weird doing entity metadata

#

Copy the EasyMetadataPacket stuff

#

add BlockPosition stuff

quaint mantle
#

hmm

#

okay

tidal skiff
#

cuz it can tell if its shift clicked in

#

but not if its dragged in

tidal skiff
#

it is an inventory click event

echo basalt
quaint mantle
#

yh yh will test it out

echo basalt
#

idk what the block metadata stuff is

calm whale
tidal skiff
#

i cant rly get this thing to work so is checking every millisecond if the players helmet is a custom item a bad idea?

quaint mantle
echo basalt
#

Did you set the block id on the spawn packet?

quaint mantle
#

yup

echo basalt
#

packet.getIntegers().write(3, Block.getCombinedId(iBlockData));

quaint mantle
#

into the spawn packet?

spiral pewter
#

How would i make dynamic events

#

like I want to make a class where i can pass in a lambda and a event class and it would register an event that runs the lambda

paper viper
#

take a look at that for example on how Conclure does it

calm whale
#

Does anyone know if there is a place with documentation about net.minecraft.server package code ?

quaint mantle
echo basalt
#

Weird

#

Try debugging the sent packets and spawning some the bukkit way

#

and seeing what you're doing wrong

#

also keep in mind the spawn entity packet is weird

#

and has an EntityType you gotta override

quaint mantle
#

yes I did

#

let me send you the thing I have now

echo basalt
#

Legit how I figure client-side entities is just debugging the spawn and metadata packets

quaint mantle
echo basalt
#

Server version?

quaint mantle
#

1.16.5

echo basalt
#

ok

#

Falling Block id is 26 on 1.16.5

#

not 31

#

31 is actually Guardian

quaint mantle
#

oh

echo basalt
#

Also try this

packet.getEntityTypes().writeSafely(0, EntityType.FALLING_BLOCK);

quaint mantle
#

that is in which packet?

echo basalt
#

Spawn

quaint mantle
#

don't think it has getEntityTypes

echo basalt
#

for some reason it makes a difference

#

getEntityType idk

#

getEntityTypeModifier

quaint mantle
#

oh okay

#

yup still the same old invisible block lmao

echo basalt
#

Send full code

quaint mantle
#

like the updated packet handler class?

echo basalt
#

yeah

quaint mantle
tidal skiff
#

anyone know whats wrong with this?

                for(ItemStack i : p.getInventory().getContents()){

                    if(i.getItemMeta().getDisplayName().equalsIgnoreCase("Miner Helmet")) {
                        if (i.getItemMeta().equals(ItemManager.wornMinerHelmet)) {

                            i.setType(Material.GOLDEN_HELMET);
                            i.setItemMeta(ItemManager.minerHelmet.getItemMeta());
                            break;

                        }
                    }
quaint mantle
#

check if it has a display name

#

and an item meta just to be sure

echo basalt
#

Also one thing you're doing wrong is

tidal skiff
#

yeah ik

#

anvils

#

it was just a debug thing

echo basalt
#

You need to write the 3rd integer on SpawnPacket as the block combined id

tidal skiff
#

ok im doing if(i.hasMeta)

echo basalt
quaint mantle
tidal skiff
#

oh dang im checking if the getitemmeta is an item not an item meta

echo basalt
quaint mantle
#

f still invisible lmao

quaint mantle
tidal skiff
quaint mantle
#

you don't even know how many times I heard the landing sound now

tidal skiff
#

again it was a debug thing

quaint mantle
#

lmao

tidal skiff
#

at me.gamma.mininghelmet.mininghelmet.MiningHelmetFunctionality.run(MiningHelmetFunctionality.java:31) ~[?:?] help

#

java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.hasItemMeta()" because "i" is null

echo basalt
#

a -> EntityId
b -> EntityUUID
c -> x
d -> y
e -> z
f -> velX
g -> velY
h -> velZ
i -> pitch
j -> yaw
k -> EntityType
l -> data

tidal skiff
#

i is for(ItemStack i : p.getInventory().getContents())

quaint mantle
echo basalt
#

instead of writing 31 try writing the block id

#

as the EntityType is the thing doing the ids

quaint mantle
#

i is null if the slot is null

tidal skiff
#

so should i do if(i != null)

quaint mantle
#

yes

tidal skiff
#

alr

quaint mantle
#

or, if (i == null) {
continue
}

quaint mantle
echo basalt
#

so yeah L is actually your data

#

the combined id

tidal skiff
#

but that would continue only if the itemstack is null

quaint mantle
undone axleBOT
echo basalt
#

Block.getCombinedId(fromMaterial(Material.STONE)) for example

#

yo imaginedev can you create a thread for this as it's quite complex?

quaint mantle
#

i cant create threads atm

echo basalt
#

ehh ok

quaint mantle
#

f

echo basalt
quaint mantle
#

can you just dm me?

#

I think I am spamming this a bit too much lmao

echo basalt
#

packet might trip so just

PacketPlayOutSpawnEntity spawnpacket = new PacketPlayOutSpawnEntity(
  ENTITY_ID++,
  UUID.randomUUID(),
  location.getX(),
  location.getY(),
  locaiton.getZ(),
  location.getPitch(),
  location.getYaw(),
  EntityTypes.FALLING_BLOCK,
  Block.getCombinedId(fromMaterial(Material.STONE)),
  Vec3D.ORIGIN);
#

and send it manually

quaint mantle
#

okay let me try it out

#

omg

#

it works

#

bruh I spent a day on this stupid falling block lmao

echo basalt
#

lmao

#

ping me whenever you need help

quaint mantle
#

sure thing

echo basalt
#

and maybe follow me on spigot so I can say I'm famous

quaint mantle
#

gonna need to add velocity and stuff so yeah

#

lmao k

echo basalt
#

change Vec3D.ORIGIN to new Vec3D(xVel, yVel, zVel)

quaint mantle
#

yeah I will need to do some weird stuff besides that initial one, will ping if anything

quaint mantle
echo basalt
#

just google my name as I'm synced

tidal skiff
#

which item slot is the helmet? ive looked at multiple sources and theyre all different 🤔

quaint mantle
#

yup followed

echo basalt
tidal skiff
#

when said 103, one said 5, one said 36...

tidal skiff
#

im so confused

echo basalt
#

that's wrong

#

that's protocol ^

quaint mantle
#

yh

echo basalt
#

this is the current one

quaint mantle
#

best skin

tidal skiff
#

lmfao

echo basalt
#

copied off google

quaint mantle
echo basalt
#

then send a velocity packet

#

since we're doing nms packets anyways might aswell

quaint mantle
#

will do then

#

coolio works

sour mica
#

Regarding PlayerInteractAtEntityEvent does it fire as well as Armorstandmanipulateevent ? or is it one or the other?

#

its wierd because the JD says Note that interacting with Armor Stands fires this event only and not its parent and as such users are expressly required to listen to this event for that scenario. referencing the PlayerInteractAtEntityEvent

#

I would have thought the Armour stand event

wintry radish
#

Hi, is there a plugin that randomly creates a scoreboard that counts a random blocks crafted ? Or I have to manually do it ?
I wanna do that each round you need to mined a new block to win in a normal generated world

unkempt peak
#

Maybe later I can

#

@wintry radish if you want me to make it dm me the info and I'll make it when I have time

quaint mantle
tidal skiff
#

is config.yml safe for passwords and stuff? like how some servers ask you to sign up and login when u connect

#

im guessing its not

bitter mural
#

Is there a way to tell if a chunk is eligible for Random Ticks? Other than, of course, regularly checking if a player is in range? ChunkUnloadEvent is too far away

silk mirage
#

How do I create a new main world with new seed

kindred valley
#

hey

#

i made an event like that but its not working

kindred valley
#
    public void onClamp(final PlayerInteractAtEntityEvent e) {

        Player player = e.getPlayer();
        final Entity clickedEntity = e.getRightClicked();

        if (clickedEntity instanceof Player) {

            ItemStack kelepce = new ItemStack(Material.TRIPWIRE);
            ItemMeta meta_kelepce = kelepce.getItemMeta();
            meta_kelepce.setDisplayName(ChatColor.GRAY + "Kelepçeler");
            ArrayList<String> lore = new ArrayList<>();
            lore.add(ChatColor.DARK_BLUE + "Polislere Özgüdür");
            lore.add(ChatColor.DARK_BLUE + "Kişileri Kelepçeleyip Soymaya Yarayabilir.");
            meta_kelepce.setLore(lore);
            meta_kelepce.addEnchant(Enchantment.PROTECTION_FALL, 1, true);
            kelepce.setItemMeta(meta_kelepce);



            if(kelepce.isSimilar(player.getInventory().getItemInMainHand())) {

                player.sendMessage("blabalbla");


                    player.openInventory((Inventory) clickedEntity);
            }

        }
    }```
waxen plinth
#

Nothing that stores passwords in plaintext is a good idea

#

You should salt and hash them

#

If you do that, then sure, store them in a yaml, it doesn't matter

kindred valley
waxen plinth
#

Most likely the item comparison is failing

#

Add debug output

#

And keep a single instance of the special item instead of recreating it everywhere you need it

kindred valley
#

how can i take this custom item from another class

silk mirage
#

How do I create a new main world with new seed

waxen plinth
#

This never gets less exhausting

silver cove
kindred valley
#


    static final ItemStack kelepce = new ItemStack(Material.TRIPWIRE);
    ItemMeta meta_kelepce = kelepce.getItemMeta();
    meta_kelepce.setDisplayName(ChatColor.GRAY + "Kelepçeler");
    ArrayList<String> lore = new ArrayList<>();
    lore.add(ChatColor.DARK_BLUE + "Polislere Özgüdür");
    lore.add(ChatColor.DARK_BLUE + "Kişileri Kelepçeleyip Soymaya Yarayabilir.");
    meta_kelepce.setLore(lore);
    meta_kelepce.addEnchant(Enchantment.PROTECTION_FALL, 1, true);
    kelepce.setItemMeta(meta_kelepce);
    
}```
#

should be like that?

silver cove
#

your items should be like that

#

in another class

kindred valley
#

yes this is another class

silver cove
#

and then u can refer to them with Namespace.item

#

ur making all ur variables static final

#

wait nvm I'm blind lol

silver cove
kindred valley
silver cove
#

because u should put it in a method

#

and make that return an itemstack

#

have a look at that

kindred valley
#

i know methods

#

i just know where to use them

#

did

#

now i need to create constructor on Utility.java ?

silver cove
#

that's if u went with step 2

#

now u can access them from the other class with Utility.thing

kindred valley
#

empty constructor

#

?

#
    private ItemStack kelepce;
    public Utility(ItemStack kelepce) {
        
        


    }

    public void utiliyty(){

    ItemStack kelepce = new ItemStack(Material.TRIPWIRE);
    ItemMeta meta_kelepce = kelepce.getItemMeta();
    meta_kelepce.setDisplayName(ChatColor.GRAY + "Kelepçeler");
    ArrayList<String> lore = new ArrayList<>();
    lore.add(ChatColor.DARK_BLUE + "Polislere Özgüdür");
    lore.add(ChatColor.DARK_BLUE + "Kişileri Kelepçeleyip Soymaya Yarayabilir.");
    meta_kelepce.setLore(lore);
    meta_kelepce.addEnchant(Enchantment.PROTECTION_FALL, 1, true);
    kelepce.setItemMeta(meta_kelepce);

   }
}```
#

should be like that?

#

i dont know what type constructor do i need to use

#

public Utility(ItemStack kelepce)

#

or empty constructor like

#

public Utility()

hybrid spoke
#

parameter one does nothing and your empty constructor should throw compile errors

kindred valley
#

i need to use ItemStack parameter? i mean on constructors parameter

hybrid spoke
#

so you just answered your own question then

kindred valley
#

but then if i need to use this constructor another class it wants me a ItemStack parameter on ()

chrome beacon
#

You always have to give it an itemstack doesn't matter where

kindred valley
#

private ItemStack item;

#

?

chrome beacon
#

?

kindred valley
#

im typing

torn oyster
#

how do i play a sound to a player through bungeecord

chrome beacon
#

I mean an ItemStack instance

chrome beacon
kindred valley
#

Handcluffs handcluffs = new Handcluffs(TO HERE RIGHT?)

torn oyster
chrome beacon
#

PlaySound I think it's called

torn oyster
#

how do i send a packet in bungee

kindred valley
chrome beacon
kindred valley
#

it says Cannot resolve symbol 'kelepce'

#

kelepce means handcluff

hybrid spoke
quaint mantle
#

would anyone be able to direct me to a resource in NMS where i make mobs head back to a certain location

#

bit of an ask but i cant find a resource anywhere

chrome beacon
quaint mantle
#

simple context, i have a bear bos

#

if it chases a player it will fall off

#

i need to TP it back i it falls off the mountain

#

and i need it to walk back to its cave when possible to avoid the above

chrome beacon
#

Why are you using NMS for this

#

*want

#

Anyway it should just be a teleport method

quaint mantle
#

as far as i know if you give it a set of pathfinders to follow or rules on the move function it shoudl be fine

#

i dont think bukkit has a way to do it

chrome beacon
#

No for the teleport

#

Pathfinding has to be NMS

#

Anyway NMS should have a teleport method too

tribal holly
#

Hi is there a way for recipe exact choice that if you rename your custom item it not broke the craft ? (my custome item has persistan data container, CMD etc...)

worn tundra
#

Your own crafting handler

#

That listens to the crafting events

tribal holly
#

i register them

#

so i'm not handling the craft event

#

and i don't really want to

quaint mantle
#

but i feel like that will be laggy considering how often it runs

burnt current
#

Hey! Does anyone happen to know how to set the direction of stairs? I have already tried with the following code:

location.add(1,4,4).getBlock().setType(BRICK_STAIRS);
                Stairs stairs1 = (Stairs) player.getWorld().getBlockAt(location.add(1,4,4)).getBlockData();
                stairs1.setFacing(BlockFace.WEST);
                player.getWorld().getBlockAt(location.add(1,4,4)).setBlockData(stairs1);

but then I get the following error through the console: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData cannot be cast to class org.bukkit.block.data.type.Stairs

This refers to the following line:
Stairs stairs1 = (Stairs) player.getWorld().getBlockAt(location.add(1,4,4)).getBlockData();

can anyone help me there by any chance?

quaint mantle
#

@waxen plinth Hello ! I'm looking at your lib ItemTrait class. I think TYPE comparison will not work fully on <1.13 versions (because the data byte should be part of this comparison in those versions). It may also be the case for DURABILITY. Since I did not tested it nor need this modification, I did not created an issue on your repository. I just want to ask you the question : Am I right or will TYPE and DURABILITY comparison work even on 1.12 ? ( https://github.com/Redempt/RedLib/blob/master/src/redempt/redlib/itemutils/ItemTrait.java )

#

Btw congrats for the lib. It's a very good work you've choose to share freely and open source with the community !

lost matrix
lost matrix
#

Oh you mean <1.13

still wing
#

package Smile;

import org.bukkit.Bukkit;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class Smile extends JavaPlugin {

public void onEnable () {
    
}
public void onPlayerChat (AsyncPlayerChatEvent event) {
     
        
       event.getMessage (). equals ("2");
                      
          
            }

}

tame coral
#

?paste

undone axleBOT
still wing
#

help

tame coral
#

Please

tame coral
#

Instead of flooding the channel

lost matrix
tame coral
lost matrix
lost matrix
lost matrix
tribal holly
#

cause it need to be exaclty the same item has register

lost matrix
#

Yes. The workaround is a custom handler that is mapped to a MaterialChoice recipe.

#

Where you can define your custom Predicate<ItemStack> as ingredients.

quaint mantle
# lost matrix Oh you mean <1.13

indeed. Is this method to check the equality of 2 ItemStacks working on both mc == 1.12 and mc >= 1.13 ?

public boolean hasSameDurability(ItemStack a, ItemStack b) {
        if (a.hasItemMeta() != b.hasItemMeta()) {
            return false;
        }
        if (!a.hasItemMeta()) {
            return true;
        }
        boolean isADamageable = a.getItemMeta() instanceof Damageable;
        if (isADamageable != (b.getItemMeta() instanceof Damageable)) return false;
        if (!isADamageable) return true;
        return (((Damageable) a.getItemMeta()).getDamage() == ((Damageable) b.getItemMeta()).getDamage());
}
grim ice
#

anyone may help find spaghetti? its prob all my code but some solutions or suggestions of what i can do are really appreciated https://github.com/2Hex/Teams

i was only trying to get the plugin to work, now its working fine i think i can start improving the code

GitHub

Teams. Contribute to 2Hex/Teams development by creating an account on GitHub.

#

yeah ik my chatevent is inside of my cmds

#

class

#

dont bully pls

celest oasis
#

How can this exist?

the return value of "org.bukkit.inventory.PlayerInventory.getItem(org.bukkit.inventory.EquipmentSlot)" is null
grim ice
#

check if its not null

#

easy

celest oasis
#

No I mean how can that happen when the getItem is @NotNull ?

grim ice
#

equipmentslot isnt

#

ez

celest oasis
#

player.getInventory().getItem(equipmentSlot).getType()

I check the equipmentSlot var and it isn't null tho

candid galleon
#

well that's just a constant for

#

it will always result in totalEXP being increased by the same amount

#

run the code, see the increment, and just totalEXp += that amount

lost matrix
#

getItem() returns null

torn oyster
#

how do i set all values that are == a certain object to null

#

in a hashmap

lost matrix
#

hashmaps dont support null values

torn oyster
#

what do

#

no

#

hashmaps do

lost matrix
#

Ah wait. They support null values.

torn oyster
lost matrix
#

Why do you want to set null values in there?

torn oyster
#

cuz

torn oyster
lost matrix
torn oyster
#

equals

#

im trying to set all values that are equal to a player

#

to null

celest oasis
lost matrix
#

Ok. But why. Can you please paint a picture (metaphorically) so i can
suggest you a better solution?

torn oyster
#

this is the best way

lost matrix
lost matrix
celest oasis
#

my bad that was getLevel(player, type) not the level variable

#
int level = getLevel(player, type);
totalExp += ((50.0 / 2.0) * level * (level + 1));
quaint mantle
#

I need to know if, in spigot1.12, there is a way to know if I should use the data byte when comparing ItemStacks type.
For example :

  • wool can be colored so I want to check data to be sure the ItemStack has the same color.
  • a redstone block can't be colored so I don't want to check the data.
  • a helmet is not colorable so I don't want to check the data. Moreover, if I do I may compare durability and I don't want that.

I tried to code this but I'm unsure that it will work :

public boolean isTypesEquals(ItemStack a, ItemStack b) {
        if (a.getType() != b.getType()) return false;
        if (VersionResolver.getNms().getVersion() <= 1.12) {
            boolean isAColorable = a instanceof Colorable;
            if (isAColorable != (b instanceof Colorable)) return false;
            if (!isAColorable) return true;
            return (((Colorable) a).getColor() == ((Colorable) b).getColor());
        }
        return true;
}
torn oyster
lost matrix
torn oyster
#

its hard to explain

#

and i just wanna know

#

how to do it

candid galleon
#

map.removeIf(a!=null && a.equals(player));

lost matrix
# torn oyster how to do it

Example:

  private final Map<String, Player> somePlayerMap = new HashMap<>();
  // PS this is dirty. Dont do that
  public void nullifyAllValuesThatEqual(final Player player) {
    for (final String key : new ArrayList<>(this.somePlayerMap.keySet())) {
      if (this.somePlayerMap.get(key).equals(player)) {
        this.somePlayerMap.put(key, null);
      }
    }
  }
lost matrix
candid galleon
#

ah

#

i see

lost matrix
#

Dont ask me why. He didnt want to elaborate,

dim bluff
candid galleon
#

map.replaceAll((k, v) -> (v != null && v.equals(player)) ? null : v);

#

in that case then

lost matrix
#

I wonder if this is reflected in the actual map:

  public void nullifyAllValuesThatEqual(final Player player) {
    this.somePlayerMap.entrySet().forEach(entry -> {
      if (player.equals(entry.getValue())) {
        entry.setValue(null);
      }
    });
  }
#

I think so

lost matrix
dim bluff
#

for the code....

#

config

lost matrix
candid galleon
#

null values can be handy in a map

#

though can definitely lead to unintended consequences

lost matrix
#

Maps return null if the key doesnt exist so this is indistinguishable from just no entry.

celest oasis
#

What's the error tho?

candid galleon
#

containsKey differentiates

celest oasis
#

What did it print?

lost matrix
# dim bluff for the code....

Ok so first:
Dont constantly load values from your config on runtime.

  1. Load all data from your config into data structures when the server starts (onEnable)
  2. Use them on runtime
  3. Save them back to the config when server stops (onDisable)
candid galleon
#

pretty sure configs are cached

#

im almost certain actually

lost matrix
candid galleon
#

if you know what you're doing having null values can be useful

#

probably not what this person wants, but it is a valid approach sometimes

lost matrix
lost matrix
candid galleon
#

I've used it previously but forget how I did

#

here's an example from SO

#
One example of usage for null values is when using a HashMap as a cache for results of an expensive operation (such as a call to an external web service) which may return null.

Putting a null value in the map then allows you to distinguish between the case where the operation has not been performed for a given key (cache.containsKey(someKey) returns false), and where the operation has been performed but returned a null value (cache.containsKey(someKey) returns true, cache.get(someKey) returns null).
#

The benefit of storing the value null against a key in a HashMap is the same as in databases, etc - you can record a distinction between having a value that is empty (e.g. string ""), and not having a value at all (null).

dim bluff
#

seems weird...

lost matrix
dim bluff
#

eh I just need it to work xD. It cant be that bad....

lost matrix
dim bluff
#

well after it works I can make it look better... it just doesnt work at all sooo...

#

I'm just trying to get a map of Materials, Integer from a config file 😢

lost matrix
dim bluff
#

ugh I'll do a class then

celest oasis
#

So the weird thing was that at the very start you already have 50 totalExp?
Also once you reach level 2 it jump another 50?

lost matrix
# dim bluff ugh I'll do a class then

Here is a template:

public class ItemData {

  private final Map<Material, Integer> itemDataMap = new HashMap<>();

  public void addValue(final Material material, final int value) {
    this.itemDataMap.put(material, value);
  }

  public int getValue(final Material material) {
    return this.itemDataMap.getOrDefault(material, 0);
  }

  public void loadFrom(final FileConfiguration configuration) {
    // Load your map data from the config
  }

  public void saveTo(final FileConfiguration configuration) {
    // Save your map data to the config
  }

}
#
  private ItemData itemData;

  @Override
  public void onEnable() {
    this.itemData = new ItemData();
    final FileConfiguration configuration = this.getConfig();
    this.itemData.loadFrom(configuration);
  }

  @Override
  public void onDisable() {
    final FileConfiguration configuration = this.getConfig();
    this.itemData.saveTo(configuration);
    this.saveConfig();
  }
celest oasis
#

@quaint mantle

int level = getLevel(player, type);
totalExp += ((reqEXP / 2.0) * (level - 1) * level);

try this then

dim bluff
opal juniper
#

you need to work out what data you need de/serialised

#

save that

#

and whether you save it as json, or more like yaml is up to you

still wing
celest oasis
still wing
#
package Smile;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;

public class Handler implements Listener {
    @EventHandler
    public void onPlayerChat (AsyncPlayerChatEvent event) {
        
        
           event.getMessage (1). equals ("2");
                          
              
                }
                
    
    
    
}

#

not working

lost matrix
# dim bluff my problem is the loadFrom part. I understand the part of changing/saving the co...
  public void loadFrom(final FileConfiguration configuration) {
    final ConfigurationSection dataSection = configuration.getConfigurationSection("items"); // Get the section
    if (dataSection == null) { // Check if it actually exists
      return;
    }
    for (final String key : dataSection.getKeys(false)) { // Go through all keys in that section
      final Material material = Material.matchMaterial(key); // Translate the key to a Material
      if (material == null) {
        continue;
      }
      final int value = dataSection.getInt(key); // Get the value mapped to that key
      this.itemDataMap.put(material, value); // Put both in the map
    }
  }

  public void saveTo(final FileConfiguration configuration) {
    final ConfigurationSection dataSection = configuration.createSection("items");
    for (final Material material : this.itemDataMap.keySet()) {
      final int value = this.itemDataMap.get(material);
      dataSection.set(material.toString(), value);
    }
  }
lost matrix
still wing
#

how?

#

eclipce

lost matrix
lost matrix
still wing
#
public class Handler implements Listener {
    @EventHandler
    public void onPlayerChat (AsyncPlayerChatEvent event) {
        
        
           event.getMessage (insert here what he writes?). equals ("and what will be displayed here?");
                          
              
                }
                
    
    
    
}
dim bluff
quaint mantle
#

Just boolean lol

still wing
quaint mantle
#

🤣

still wing
dim bluff
lost matrix
dim bluff
#

can I just do this? and change the function to static. I'm not even sure what a "FileConfiguration" is

lost matrix
#

An instance of a class can be created using the new keyowrd

dim bluff
#

so I make a constructor in the ItemData class?

still wing
#

sorry, of course, but what are you talking about?

lost matrix
dim bluff
#

ohhhh

#

something like this?

lost matrix
dim bluff
#

and now I'm supposed to have a map?

lost matrix
# dim bluff and now I'm supposed to have a map?

The map is inside the instance of your ItemData class.
Every time you create an instance of a class, all the fields and methods inside
the instance are created.
So you can have several instances of ItemData

    final ItemData dataA = new ItemData();
    final ItemData dataB = new ItemData();

And each instance will have their own content. Completely new.
You can now call all the methods you created in your ItemData by just using
instance.method(params)

dim bluff
#

how do I load it in another class if its not static?

#

Like getting the ItemData in my Listeners class

lost matrix
# dim bluff how do I load it in another class if its not static?

Other classes that need an instance of this class should request that in their constructor.
So if you want the exact instance you loaded your config into, in another class you need to
pass it via the constructor.

public class SomeListener implements Listener {

  private final ItemData itemData;

  public SomeListener(ItemData itemData) {
    this.itemData = itemData;
  }

  @EventHandler
  public void onSomething() {
     // Use this.itemData to access the data
  }

}

Then you pass this exact instance to other classes.

    final ItemData dataA = new ItemData();
    dataA.loadFrom(config);

    SomeListener listener = new SomeListener(dataA);

    Bukkit.getPluginManager().registerEvents(listener, this);

Just make sure you dont have new instances for different classes. You want
this instance everywhere.

dim bluff
#

kk think I did it, now in my "SomeListerner" class. How do I call the map. cant seem to find I'm just testing stuff

lost matrix
#

You dont want to get the map directly.

dim bluff
#

well call the function

#

liek do a getValue()

lost matrix
#

the ItemData class has methods that access the map. But the map itself is never exposed.

#
    Material material = ...; // Get Material from event somehow
    int materialValue = this.itemData.getValue(material);
burnt current
dim bluff
#

I might have messed up my config file tho

#

is this correct?

#

maybe missing spaces

lost matrix
lost matrix
tacit drift
#

And you need to matchMaterial from string

#

oh nvm

dim bluff
#

the prob is I might want to get difference between enchanted golden apple and normal golden apple

dim bluff
#

is not saying anything

lost matrix
#

Enchanted golden apple has its own type

items:
  ENCHANTED_GOLDEN_APPLE: 1000
  GOLDEN_APPLE: 12
  STEAK: 420
dim bluff
#

😢

lost matrix
dim bluff
lost matrix
# dim bluff

Before we pursue your problem:
Free your code from all the static keywords.
Make Main plugin private final and non static and request it via the constructor.

lost matrix
# dim bluff

Btw you register your listeners twice.
Remove the registration in the constructor,

dim bluff
#

oh yep... removed

lost matrix
# dim bluff

You should also see an exception in your console. Because your config will always be null.
You created a variable but never put anything in there. So it will always be null.
Check your console for exceptions when the server starts.

dim bluff
#

umm... alot is happening in the console

#

there is in fact a NullPointerException

calm whale
lost matrix
#

You declared your config variable. Which will make it null by default.
Then you put nothing in there.
Then you used it. -> null pointer

lost matrix
dim bluff
#

should I put something in it at like my onEnable or just in my Listener

calm whale
lost matrix
dim bluff
#

kk

lost matrix
dim bluff
#

hmm so I got a message for eating a GOLDEN_APPLE in game but its 0 not 12... good start tho 🙂

lost matrix
dim bluff
#

config.yml looks like this

smoky oak
#

assuming itemdata.getValue is a function you wrote, would you mind posting the code?

calm whale
lost matrix
lost matrix
calm whale
#

ok

#

isn't it too heavy ?

dim bluff
#

so I don't have a keySet I guess that would be a problem 🙂

lost matrix
# dim bluff "I wrote" 🙂

You should try debugging that so you understand whats happening in there.
Just add some System.out.println() into the code and print out different infos like
the the materials that are laoded, what values where loaded etc

lost matrix
calm whale
#

ok

dim bluff
#

doesnt return anything.... maybe its cuz they're materials... idk

#

its just a []

lost matrix
dim bluff
#

😢 again a problem with loading the map I guess

#

I'll do some more tests

smoky oak
# dim bluff "I wrote" 🙂

Assuming the issue is where i think it is, it either thinks you're loading the wrong/an empty config, or not loading in the HashMap correctly. Do what 7smile7 said and add console logs at key points - for example, print out the result from dataSection.getKeys(false)

#

also are you using the correct config file?

lost matrix
dim bluff
smoky oak
#

found it

#

you never assign the config variable the actual FileConfiguration

lost matrix
smoky oak
#

oops

lost matrix
#

I think the code itself is fine btw. The problem is probably related to the config.yml

smoky oak
#

the config looks fine tho

dim bluff
#

its literally just printing 76

#

wtf

smoky oak
#

?

dim bluff
#

what is 76

smoky oak
#

that number isnt even in your code is it...

dim bluff
#

lmao no

lost matrix
dim bluff
#

oopd

#

maybe I'm running the wrong file

smoky oak
#

well you said you assigned the config to the config variable

#

so im assuming it is

lost matrix
#

Yeah but that doesnt mean its loaded from/saved to disk

dim bluff
#

?...

smoky oak
#

how do you guys assign the config atm?

dim bluff
smoky oak
#

um

dim bluff
#

idk

#

config stuff

smoky oak
#

it should work when you start theplugin twice

#

urgh

#

youre first assigning the variable but that code should save the config to the disk

#

im unsure if this could cause problems here

#

but it shouldnt

#

well im out of ideas

calm whale
#

ok @lost matrix it looks better but still not that :/

smoky oak
#

hence

#

start it twice

calm whale
#

I have no clue what cause the empty areas

lost matrix
# calm whale

Render the map some ticks after you added the tickets. Maybe 5 or so.

hybrid spoke
calm whale
#

actually I add tickets to every chunk in the area, I stock them in a list, I render the map, then I unload the tickets through the list, is it wrong ?

lost matrix
lost matrix
#

so far

dim bluff
#

nothing is printing xD

#

is it normal I don't use plugin

#

idk

lost matrix
quaint mantle
#

Imagine naming it main

smoky oak
#

dumb question of my own now:

saveResource(configFile, false);
return YamlConfiguration.loadConfiguration(new InputStreamReader(getResource(configFile)))

This should just save the resource to the disk and return said file right?

#

...why is it the second i ask something everyone is just gone

lost matrix
smoky oak
#

well that still results in the same as if i would load that file in right?

dim bluff
#

ok so I feel like the problem is that my config file like "GOLDEN_APPLE" is not saving as Material.GOLDEN_APPLE

lost matrix
next stratus
#

Hey 7smile, I have noticed what you mean about the creative mode being unreliable. 🥲

smoky oak
#

ah well its inside a function that first checks if that file already exists. I figured it would be easier doing that than to add the 20 lines of code to load in a file from disk

lost matrix
# dim bluff ok so I feel like the problem is that my config file like "GOLDEN_APPLE" is not ...

All you need is this:

  private ItemData itemData;

  @Override
  public void onEnable() {
    this.saveDefaultConfig();
    this.reloadConfig();
    final FileConfiguration configuration = this.getConfig();

    this.itemData = new ItemData();
    this.itemData.loadFrom(configuration);

    final SomeListener listener = new SomeListener(this.itemData);
    Bukkit.getPluginManager().registerEvents(listener, this);
  }

  @Override
  public void onDisable() {
    final FileConfiguration configuration = this.getConfig();
    this.itemData.saveTo(configuration);
    this.saveConfig();
  }
next stratus
#

7smile, has creative mode always been unreliable for these things do you know?

lost matrix
calm whale
candid galleon
#

update is called every tick

lost matrix
next stratus
#

Ah, I see.

candid galleon
#

so you're scheduling a new method 5 ticks later, every tick

#

what are you trying to do?

next stratus
#

If only it was handled the same way as survival 🥲

lost matrix
calm whale
#

of course once

candid galleon
#

you could try merely adding a boolean of whether it was rendered or not

dim bluff
lost matrix
candid galleon
#

if it has, return

calm whale
#

ah fuck used the wrong xD

smoky oak
#

oh lol

lost matrix
calm whale
#

what should I use then ?

dim bluff
#

... still showing that keySet is empty tho

smoky oak
#

your config.yml isnt in your ressources folder i think

dim bluff
#

keySet has no materials

young knoll
#

If you don’t use a build tool the config.yml should be in the root folder

smoky oak
#

to be fair i dont exactly know how eclipse works but still

lost matrix
#
    public void update(MapView mapView) {
        if(this.alreadyRendered) {
          return;
        }
        ArrayList<org.bukkit.Chunk> chunks = new ArrayList<>();
lost matrix
#

src path is fine

smoky oak
#

i prefer to use maven if just for the fact that it's typing three words and done

calm whale
#

(I have reduce the chunks number to test quickly, btw it still bugging)

#

and I didn't understand why you said that it was rendering every tick

#

it seems to be correct to execute once 🤷‍♂️

dim bluff
#

How do I sysout stuff in the ItemData folder?

lean gull
#

anyone know why i can't do team.setColor outside the createRank method?

public class Teams implements Listener {

    public static Team createRank(String name) {
        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard board = manager.getNewScoreboard();
        Team team = board.registerNewTeam(name);
        return team;
    }

    Team team = createRank("OWNER");

}```
#

or any other option

lost matrix
calm whale
#

still bugged

candid galleon
#

you're also redeclaring it outside of any valid scope

#

oh i see

lost matrix
lean gull
#

still don't know what a constructor is, also i swear to god if you say learn java i will block you

lost matrix
lost matrix
candid galleon
#

@lean gull only variable declaration is allowed outside of scope (what you're doing)

lost matrix
#

You cant.

young knoll
#

Team is a local variable, so you can’t access it outside that method

lean gull
#

ok so what do i do

candid galleon
#

the code is ran "all at once", if it's not in a method, so there is no order to it, so you can't add on to it

young knoll
#

?learnjava

undone axleBOT
lost matrix
calm whale
#

here is the outcome, I have reduced to 16x16 chunks to go faster

lean gull
#

again, i do not know what a constructor is

lost matrix
calm whale
#
MapView map = Bukkit.createMap(Bukkit.getWorld("world"));

                            map.setCenterX(0);
                            map.setCenterZ(0);
                            map.setTrackingPosition(true);
                            map.setUnlimitedTracking(true);
                            map.getRenderers().clear();
                            map.addRenderer(new MapRenderer() {

                            @Override
                                public void render(@NotNull MapView mapView, @NotNull MapCanvas mapCanvas, @NotNull Player player) {

                                    MapCursorCollection cursors = new MapCursorCollection();

                                    cursors.addCursor(new MapCursor((byte) 0, (byte) 0, (byte) 12, MapCursor.Type.RED_X, true));
                                    mapCanvas.setCursors(cursors);

                                }
                            });

                            new MapUpdater(Bukkit.getWorld("world")).update(map);

                            ItemStack m = new ItemStack(Material.FILLED_MAP);
                            MapMeta mm = (MapMeta) m.getItemMeta();
                            mm.setMapView(map);
                            m.setItemMeta(mm);
                            m.setDurability((short)mm.getMapId());

                            p.getInventory().addItem(m);

that's how I create the map, then here is how I try to load it: https://paste.md-5.net/uputuqivep.java

lost matrix
calm whale
#

yup

lost matrix
#

Ok then its a systematical error.

lost matrix
# calm whale yup

So if you delete the map, restart the server then the map looks exactly like the one before?

calm whale
#

yes

lost matrix
#

Ok

calm whale
#

but I copy paste the same world before restart

#

do you think the world is the problem ?

lost matrix
#

If you did load all chunks with a ticket then not.

calm whale
#

my code is exactly as it is in the paste

lost matrix
#

x += 64
You increment by 64 even when the map is 16x16

#

@calm whale

#

Wait this is scale dependent, right.

calm whale
#

yep

lost matrix
#

Those are my 3 takes:
Increase delay from 5 to 10 ticks
play around with the raw y position
change the increment based on your maps size

calm whale
#

I don't think the y matters, the proof is that we get some parts of the map

lost matrix
calm whale
#

what do you suggest ? use the higest y ?

candid galleon
#

running getRenderers().clear() doesnt remove the renderers

#

you have to use removeRenderer

smoky oak
#

java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because the return value of "org.bukkit.event.player.PlayerInteractEvent.getItem()" is null
I have a stick in my hand.

candid galleon
#

Interact is called for both hands

#

check the hands

#

also null check the item for good coding and when you aren't holding anything

lean gull
#

i think this is a constructor, not sure, but i still can't use the options of the team

public class Teams implements Listener {

    Team team;

    public Teams(String name) {
        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard board = manager.getNewScoreboard();
        team = board.registerNewTeam(name);
    }

    Teams owner = new Teams("OWNER");

}```
lost matrix
lost matrix
# candid galleon ^^^

Yes yes. And also properly clear the renderers list.
They should really make this immutable and throw an UnsupportedOperationException there.

smoky oak
#

event.getItem().getType()!=null && event.getItem().getType().equals(Material.STICK)
Can you do that more elegant in some way

lost matrix
young knoll
#

event.getItem != null

lean gull
#

make ranks, change their color, prefixes, suffixes, stuff like that

young knoll
#

Can’t call getType on a null item

smoky oak
#

thats the only place the item in hand is important

lean gull
#

i was told to do that with teams

#

so chat won't be broken when you type something or just "%"

candid galleon
#

getType can't return null, getItem would

#

event.getItem() != null && event.getItem().getType == Material.STICK

calm whale
candid galleon
#

code?

calm whale
#

I came back on 32x32

lost matrix
calm whale
candid galleon
#

yes

calm whale
smoky oak
lost matrix
calm whale
#

xD it has always been the case

lost matrix
calm whale
young knoll
#

Doesn’t really get simpler than that

lost matrix
young knoll
#

Or you could make a util method I guess

candid galleon
#
  @EventHandler
  public void onInteract(final PlayerInteractEvent event) {
    ItemStack item = event.getItem();
    if (item == null || item.getType() != Material.STICK) {
      return;
    }
    
    // You can be sure that the item clicked with is a STICK here
  }
young knoll
#

Pass it an item and a material and have it return a Boolean

smoky oak
#

nah msws solution is thebest one her

#

as said i only need that item once and the null check is to prevent the npe

lost matrix
#
  @EventHandler
  public void onInteract(final PlayerInteractEvent event) {
    Optional.ofNullable(event.getItem()).stream().filter(this::isNotNullAndStick).forEach(this::handleStick);
  }

  private boolean isNotNullAndStick(final ItemStack itemStack) {
    return itemStack != null && itemStack.getType() == Material.STICK;
  }

  private void handleStick(final ItemStack stick) {
    // Handle stick here
  }

XDD (dont use that)

candid galleon
#

you can stream an optional?

smoky oak
#

isnt .stream() a method of the object class?

lean gull
#

still need help

lost matrix
#

Yes. Thats important for flatMaping

lost matrix
smoky oak
#

huh

hybrid spoke
smoky oak
#

I UNDERSTAND, thank you very much

#

you dont need to say it twice

#

im not that dumb

hybrid spoke
candid galleon
#

it twice

lost matrix
#

Also:

lean gull
#

how am i rude

lost matrix
undone axleBOT
lean gull
#

and blocked

lost matrix
#

"how am i rude"

#

XD

calm whale
hybrid spoke
#

lmao

young knoll
#

It’s okay, they can’t block the truth

hybrid spoke
#

poor guy

lean gull
#

im gonna take a wild guess and say that you guys think im rude because i block rude people?

hybrid spoke
#

how is smile rude

#

he even spoonfeed you

lean gull
#

he literally just told me to learn java

undone axleBOT
hybrid spoke
#

?learnjava

lean gull
#

ba da bing ba da boom, blocked

young knoll
#

You see telling someone to learn is rude

#

Because uh... yes

hybrid spoke
#

coll go learn

lean gull
#

anyone else wanna tell me to learn java?

young knoll
#

Sure

#

?learnjava

undone axleBOT
lost matrix
lean gull
#

blocked

#

i got all day

hybrid spoke
#

@opal juniper can you tell him to learn java too?

#

and @daring sierra please

smoky oak
#

I know enoug about java to hate everything new after java 8 lol

lusty cipher
#

@lean gull learn java

hybrid spoke
#

you need to ?learnjava him

lusty cipher
#

oh ok sure

hybrid spoke
#

otherwise you arent telling enough

young knoll
#

There has been a lot of good stuff post java 8

daring sierra
smoky oak
#

yea like 'record' is a interesting feature but its useless for dynamic data types

lean gull
#

i know this will make yall happy so imma just leave this server, rude people everywhere and no one actually wants to help