#help-development

1 messages ยท Page 1354 of 1

sullen dome
#

' '

wet breach
#

then use the other then lol

#

'' just means character literal. Confusing which needs to be used sometimes

sullen dome
#
bot.getGuildById("696626150553681951").getTextChannelById("826840223195070474").sendMessage(s.replace("s/\\x1B\\[[0-9;]\\{1,\\}[A-Za-z]//g", "")).queue();```
so this would be good?
#

god, leaked my discord id's

ivory sleet
#

I will hack you ofc

sullen dome
#

please no :(

kindred solar
#

xdd

sullen dome
#

my server only has like 30 people, idk if that's worth it

wet breach
#

that reminds me of the time the spigot people took over some malicious persons discord because they leaked their id stuff

#

anyways moving on....

sullen dome
#

thats just channel id's and stuff, idk if that is even bad if leaked

#

i mean it's not a bot token or smt

wet breach
#

you need to create a pattern regex object I think, unless replace detects that as regex which I doubt

kindred solar
# sullen dome please no :(

ofc no one is going to do anything here, i think the ppl who is here is just cuz needs to solve plugins problems

sullen dome
#

nobody knows

kindred solar
#

ikik

ivory sleet
#

technically I could be sleeping under your bed right now

sullen dome
#

i mean... conclure looks kinda sus tbh

ivory sleet
#

lmao

sullen dome
#

technically you wouldn't fit there

ivory sleet
#

thought the pfp of my doggo could neutralize it a bit

eternal oxide
#

if its a single character you need to replace use replaceAll as it takes a regex

wet breach
#

@ivory sleet to be fair, all that means is either we need to be concerned for your safety or theirs, doesn't really indicate who though lmao

ivory sleet
#

yeah indeed

barren locust
#

anyone know the best way to go about adding fake players to the tab menu? seems like there is little to no documentation on this for 1.16.5

wet breach
ivory sleet
#

leap arguably packets

sullen dome
eternal oxide
#

k

barren locust
sullen dome
#

but not that much, that i would trust you :/

ivory sleet
#

hmm you'd only be sending packets so you could use raw nms I guess

#

if I switch to when my dog was a puppy?

sullen dome
#

well

barren locust
#

nms is scary

#

but I will attempt

ivory sleet
#

yeah

sullen dome
#

if you would have a corgi, that would do something

#

but else... i dont know

ivory sleet
#

thats oddly specific

sullen dome
#

yeah, i am specific

ivory sleet
#

figured so much

wet breach
#

not that hard to hook into the packet stuff to do this @barren locust you can use protocollib for this, but that is quite a large library to depend on for something so small and there is plenty of examples or their used to be on hooking into the packet stuff especially for the tab menu.

#

But you can definitely use protocollib for this. To identify which packet you need, just use https://wiki.vg

barren locust
#

ty

quaint mantle
#

Anyone know about bungeecord schedulers?

lost matrix
quaint mantle
#

DId you see this message?

#

I just need to keep spamming that title or something when the player is in limbo for being AFK.

#

Because at the moment, its diapering after a few seconds of being auto AFKd.

lost matrix
#

What exactly is your 'limbo'? A whole server?

lost matrix
#

Then i would just schedule one runnable that sends a title to a specific group of ProxiedPlayers. You can just add them or their UUID to a Set and frequently send them title messages.
Just make sure to clean the Set when they change the server or quit. getProxy().getScheduler().schedule(...);

wet breach
#

@quaint mantle why are you bothering with a plugin that kicks for being afk, and then proceeding to override that ? o.O

quaint mantle
#

Can I check when the player is moving through the proxy?

lost matrix
quaint mantle
#

Hm, well In that case, I have no idea how I'm supposed to do that XD

#

Until I can learn how to listen to the packets through a bungee plugin, why can't I just check if the player is in limbo and then spam the title?

lost matrix
#

You can do that. I thought you meant physical movement.

#

There is an event for when a player changes the server.

quaint mantle
#

How about this? ```java
if(p.getServer().equals("limbo"))

lost matrix
#

Yeah... no.

#

For one getServer doesnt return a String.

#

And then its just inefficient.

quaint mantle
#

Wait what does it return then?

lost matrix
#

It returns the Server. getServer() returns the Server...

#

Big reveal

quaint mantle
#

But what do you mean by 'the Server'? Is that the name of the backend defined in the BungeeCord config?

lost matrix
#

No its the Server object. It extends Connection and represents a destination.

quaint mantle
#

Ah okay

#

Is there any way I can get a string of the server they are connected to then?

lost matrix
#

BungeeCord is a little bit more complex than writing Spigot plugins. And it looks like you are not even familiar with some of the Java basics.
So i would recommend you to write at least one or two more Spigot plugins and get familiar with the idea of proxies before you jump into writing
more stuff for BungeeCord.

lost matrix
#

And this will def help if your IDE is crippled ^

kindred solar
#

guys, i need help, im trying to update everyone's scoreboard everytime a player joins

#

i placed it onplayerjoin event but it is only updating the joined player

eternal oxide
#

you have to update it for all players. Bukkit.getOnlinePlayers()

kindred solar
#

wdym

eternal oxide
#

loop over all online players and update their scoreboard

kindred solar
paper viper
#

unless you are dealing with hundreds of thousands of players, no

#

which is something hypixel doesn't even have

#

lol

kindred solar
#

okok if u say so

#

i didnt understood the loop xd

#

i made this but ik it isnt right

#
        for(int cnt1 = 0; cnt1 < getServer().getOnlinePlayers().size(); cnt1++){
            playersOnline = o.getScore(ChatColor.WHITE + "Players: " + ChatColor.GOLD + getServer().getOnlinePlayers().size());
            playersOnline.setScore(5);
        }
limber dust
#

or Bukkit.getOnlinePlayers().foreach(player ->{ }

eternal oxide
#
Bukkit.getOnlinePlayers().forEach(player ->() {
    //code here
});```
limber dust
#

^

#

XD

eternal oxide
#

Zoon beat me to it

limber dust
#

dammit auto mod deleting my messages

kindred solar
eternal oxide
#

its forEach not foreach

limber dust
#

i just typed on discord

#

so formatting wasn't gonna be right

#
                Bukkit.getOnlinePlayers().forEach(player -> {
                    
                });```
kindred solar
#

then i paste this inside or do what? ```java
Score playersOnline = o.getScore(ChatColor.WHITE + "Players: " + ChatColor.GOLD + getServer().getOnlinePlayers().size());
playersOnline.setScore(5);

covert urchin
#

that doesn't look right to me

eternal oxide
#

are you using one scoreboard per player or the default one? or a custom one?

kindred solar
#

i think im doing per player

covert urchin
#

in particular: o.getScore(ChatColor.WHITE + "Players: " + ChatColor.GOLD + getServer().getOnlinePlayers().size()); as I don't think that string is something that it will accept as valid.

covert urchin
#

eh? But I'm reading about scoreboard in spigot and it doesn't take arguments?

eternal oxide
#

when a player joins, loop over each player, get their scoreboard and update it

eternal oxide
#

he's fetchign the score not a scoreboard. he should already have the scoreboard as 'o'

covert urchin
kindred solar
somber hull
#

I need to spawn an entity, and keep track of that entity so when it dies i can change its item drop

kindred solar
#

How do i do things every X secs

lost matrix
kindred solar
lost matrix
somber hull
#

i just dont know how to check if a entity ahs that NBT

#

cause there are no NMS documentations

#

and im using 1.12

lost matrix
#

Oh 1.12

somber hull
#

yea..

kindred solar
lost matrix
#

Its a static method from the Bukkit class

kindred solar
somber hull
drowsy helm
#

it gives you the tutorial in the readme

somber hull
drowsy helm
#

yes

lost matrix
somber hull
#
            NBTTagCompound tag = new NBTTagCompound();
            
            ((CraftEntity)bossEntity).getHandle().c(tag);
            tag.setBoolean("isboss", true);
#

i just have no idea how to read it

#

I just need someone who knows 1.12 nms

kindred solar
#

if some1 could help me i will be happy

somber hull
#

can someone just show me how to use this?

#

if its a library, i have no idea how to use it, and if someone could show me it would be great and i could use the knowledge in the future ๐Ÿ˜„

#

Do i litterally just add it as a new class in my project?

#

i just kijnda threw it in

#

and

#

i think it works?

quaint mantle
#

I'm just gonna ask again cause I found out the issue, I just don't know how to fix it. I "marked" the two things that I don't know how to fix with a comment

    public static ArrayList<Player> ChestOpen = new ArrayList<>();
    public static ConcurrentHashMap<Player, Integer> ChestsOpen = new ConcurrentHashMap<>();
    
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent e) {
        
        Player p = e.getPlayer();
        
        if (e.getClickedBlock().getState() instanceof Chest) {
            
            e.setCancelled(true);
            
            if (!(GlobalState.isState(GlobalState.WARMUP) || GlobalState.isState(GlobalState.IN_GAME))) {
                return;
            } else {
                if (ChestOpen.contains(p)) { //This one doesn't work <<<-------
                    e.getClickedBlock().setType(Material.AIR);
                    
                    if (!ChestsOpen.get(p).equals(thing.getInstance().getConfig().getInt("chests-per-player") - 1)) { //and same with this
                        int toAdd = 1;
                        int newChestsOpened = toAdd + ChestsOpen.get(p);
                        ChestsOpen.put(p, newChestsOpened);
                    } else {
                        p.sendMessage(ChatColor.translateAlternateColorCodes('&', MessagePrefix.messagePrefix() + "&7You have already opened " + thing.getInstance().getConfig().getInt("chests-per-player") + " chests!"));
                    }
                }
            }
        }
    }```
paper viper
#
  1. variable naming conventions
#
  1. use ChatColor please instead of the translate alternate color codes or make a method for it to make it not messy
#
  1. why ConcurrentHashMap? You have to have reasons for using the data structures to use
#
  1. is static necessary for the variables? Are you caching them as constants?
ivory sleet
paper viper
quaint mantle
#

@paper viper ?, thats not the issue, I have it as HashMap now either way, yes

paper viper
#

no that is an issue

#

that you need to fix

quaint mantle
#

yeah but thats not why it doesnt work

paper viper
#

well then just fix those things first

#

cause those are the basic stuff

#

you also haven't described "doesn't work"

#

any error/exception?

quaint mantle
paper viper
#

Use UUID instead

quaint mantle
#

store uuids

#

no errors btw

paper viper
#

that is quite a big issue

#

as well

ivory sleet
paper viper
#

for the Player

ivory sleet
#

Or actually you could use IdentityHashMap

#

Because it has faster lookup

#

And then ofc erase players when they log out

paper viper
#

wait

ivory sleet
#

Hmm yeah

paper viper
#

why not just uuid with hashmap

#

tho

#

lol

ivory sleet
#

Idk cumbersome for no reason

#

Unless you want data to persist even after logout

paper viper
#

ig

quaint mantle
#

still didn't really help the issue: if (ChestOpen.contains(p))

paper viper
#

You

#

literally

#

haven't

#

described

#

the

#

issue

ivory sleet
#

๐Ÿ‘

quaint mantle
#

I don't get any errors but the issue is that if (ChestOpen.contains(p)) literally just doesn't work

#

like bro

drowsy helm
#

dont use Player in collections

#

use UUID

quaint mantle
#

I AM

#

I already changed that

drowsy helm
#

have you debugged the contents of ChestOpen

ancient plank
#

have you changed the p in the check to p.getUniqueId? Since you've changed it from Player to UUID you need to change what it's checking for to check for the UUID instead of just Player

quaint mantle
#

yes, all of the p's

#

and I'm not sure but players not being added to the arraylist might be the issue?

drowsy helm
#

again, have you debugged the contents

#

or you're just going on faith

quaint mantle
#

faith ๐Ÿ™

paper viper
#

๐Ÿฅฑ

drowsy helm
#

there ya go

#

debug it and see if the uuid is even in there

#

thats probs your problem

deft sedge
#

Hello, I want to know how to let all the classes know if something happens in a different class. Is there a way to broadcast a message to all classes or something. Like for example if a player dies. I might want to tell a diffferent piece of code in another class

#

kind of like functions

paper viper
#

di

#

is useful

drowsy helm
#

whats your usecase

quaint mantle
#

or just make an event yourself

drowsy helm
#

thats pretty much what the event system is

#

but it depends on what you want to use it for

deft sedge
#

well i have a thing that if the player sleeps i want them to loose some of their hunger due to it just being a new day

ivory sleet
#

Maybe inject callbacks

deft sedge
#

so I thought I could put the hunger in one class and the sleeping in anothyer

drowsy helm
#

you could do that all in one event

deft sedge
#

Now I know this is stupid but in scaratch there is a thing where you can kind of send a message and ave seperate code that listens for said message

#

Is there a way to do that in this

#

or kind of like that

drowsy helm
#

you call the function in another class

deft sedge
#

ok

drowsy helm
#

di is dependency injection

ivory sleet
#

@paper viper

paper viper
ivory sleet
#

Hi

paper viper
#

Hola

ivory sleet
#

@paper viper howโ€™s life?

drowsy helm
#
public class MyClass1{
  public void myFunction1(){

  }
}

public class MyClass2{
  MyClass1 myclass = new MyClass1();
  myclass.myFunction1();
}```
paper viper
drowsy helm
#

was not an example of di

ivory sleet
drowsy helm
deft sedge
#

ok thanks

#

and I don't have to do any declaring in main.java right

drowsy helm
#

depends on your project setup

#

I'd really recommend learning a bit of OOP it goes a long way in plugin development

quaint mantle
#
public class MyCustomEventHandling {
    private static final List<MyInterface> INTERFACES = new ArrayList<>();

    public static void registerEvent(MyInterface myInterface) {
        INTERFACES.add(myInterface);
    }

    public static void callEvent() {
        INTERFACES.forEach(i::doMethod);
    }
}

@deft sedge

deft sedge
#

ok

quaint mantle
quaint mantle
#

So I guess it was what I thought? if (ChestOpen.contains(p.getUniqueId()))

#

show code

#

nvm ima send the more updated one

#
    private List<UUID> players = new ArrayList<>();
    public List<UUID> getPlayers() { return players; }
    
    public static ArrayList<UUID> ChestOpen = new ArrayList<>();
    public static HashMap<UUID, Integer> ChestsOpen = new HashMap<>();
    
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent e) {
        
        Player p = e.getPlayer();
        ChestOpen.add(p.getUniqueId());
        
        if (e.getClickedBlock().getState() instanceof Chest) {
            
            e.setCancelled(true);
            
            if (!(GlobalState.isState(GlobalState.WARMUP) || GlobalState.isState(GlobalState.IN_GAME))) {
                return;
            } else {
                if (ChestOpen.contains(p.getUniqueId())) {
                    e.getClickedBlock().setType(Material.AIR);
                    
                    if (!ChestsOpen.get(p.getUniqueId()).equals(TIMV.getInstance().getConfig().getInt("chests-per-player") - 1)) {
                        int toAdd = 1;
                        int newChestsOpened = toAdd + ChestsOpen.get(p.getUniqueId());
                        ChestsOpen.put(p.getUniqueId(), newChestsOpened);
                    } else {
                        p.sendMessage("too many chests message thing here yes yes later");
                    }
                }
            }
        }
    }
paper viper
#

my eyes

quaint mantle
#

yeah.

#

show chestopen class

#

oh shit thats an arraylist

paper viper
#

so much is wrong/bad practice in this code

quaint mantle
#

dude use naming conventions

quaint mantle
#

somewhere in your other code you are doing WhatEverClassThisIs.ChestOpen = null; or some sh

#

no.

#

yes.

#

actually can you just send the entire class instead of making me wonder where line 44 is?

sage swift
quaint mantle
quaint mantle
#

thats why you name your variables better

#
chestOpen.add(p.getUniqueId());
        
if (e.getClickedBlock().getState() instanceof Chest) {

you dont even see if its a chest first

#
int toAdd = 1;
int newChestsOpened = toAdd + chestsOpen.get(p.getUniqueId());

yes, lets make a final local variable with a value of 1

#

remove toAdd

#

okay removed it...

#

._.

#

?

#

I removed it but I still need a way of counting the amount of chests?

quaint mantle
deft sedge
#

I want to make code where people can type a command like for example /sleep <keyword> The keyword can be anything but if two of any players type /sleep and then the same keyword, it get's both of the player's names and just stores them to a var

dusk flicker
#

k?

deft sedge
#

is that a thing and/or is there a way to do it

dusk flicker
#

yeah

#

Store all players that are "sleeping" in a map with a keyword string

deft sedge
#

well problem is that I'm making a minigame and it has to be a command

#

it's not real mc sleeping

dusk flicker
#

How does that matter?...

deft sedge
#

it's a long story

#

i'd be happy to say

#

basically i'm making a thing where there are teams and u have to survive on an island

dusk flicker
#

just on the command add em to the map

deft sedge
#

and everyday you loose one day of thirst and whatever else

#

i need to have it where two people agree to the "sleeping" bc there are partners in the game

dusk flicker
#

????

#

Okay?

#

Not sure how this relates

deft sedge
#

Ik it's confusting

young knoll
#

Why not store the partners and then just have the command

#

Instead of needing some keyword

deft sedge
#

well becaue this is gonna be more confusing

#

i'm making this for a school calss

#

and an entire grade has to play this game

dusk flicker
#

Unless you are a beginner at java this isnt hard at all

deft sedge
#

and the taecher is not gonna buy 100 mc accoutnts

#

so i have to have a select few and I can just store data in a book

#

i'm not that beginner I can understand programming

quaint mantle
#
public class IntHolder { // Object, pass this around
    public int sleeping = 0; // turn this into getters and setters
}
deft sedge
#

for me it's more the actual how you do things

young knoll
#

Or store data in a proper format

#

Like a file or datebase

quaint mantle
#

@quaint mantle still having issues with it not going through if (chestOpen.contains(p.getUniqueId()))

dusk flicker
#

So basically you want to make it so if people execute a command to sleep, and if the keyword matches one already made send a request to the original person or whatever correct?

deft sedge
#

yea

#

exactly

dusk flicker
#

So thats easy, you are overcomplicating this some how

deft sedge
#

probably ๐Ÿ˜„

quaint mantle
#

Map<String, Boolean>

dusk flicker
#

On command

Check if map contains keyword

  • if not: add a player unique object into the map with a key of the keyword
  • if so: get the player in the map with the key of the keyword and send the request
deft sedge
#

ok

#

thanks

#

and the map can store the previous keywords right?

dusk flicker
#

you could make it

#

Its up to you

deft sedge
#

ok

dusk flicker
#

Its java, everything you tell it to do does it

deft sedge
#

ill look into maps

#

on java

#

thx for the help

quaint mantle
#

k

young knoll
quaint mantle
#

it sounds like he just wants Set<String>

deft sedge
#

i also need to get the username of the two ppl who sent the keyword if it matches

quaint mantle
#

im gonna make a somewhat-close example

dusk flicker
#

If you look in the psuedo code I sent, I said to include a player unique value

deft sedge
#

ok thanks for taking the time to help ๐Ÿ™‚ Sorry if i'm bing slow

quaint mantle
#

bing is slow

#

you are not

dusk flicker
#

oof forgot I cant use external emojis in here

quaint mantle
#
Map<String, UUID> map = new HashMap<>();

void onCommand(UUID playerUUID, String arg) { // just an ex. lol
    UUID uuid = map.get(arg);

    if (uuid != null) {
        // do stuff
        map.remove(arg);
        return;
    }
    
    map.put(arg, playerUUID);
}

@deft sedge hopefully this isnt a spoonfeed

#

just tryna give you an idea

deft sedge
#

ok thanks

crude charm
#
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project Core: Com
pilation failure: Compilation failure:
[ERROR] /E:/core/src/main/java/me/zoibox/core/core/Core.java:[5,19] cannot access dev.morphia.Datastore
[ERROR]   bad class file: C:\Users\wsmit\.m2\repository\dev\morphia\morphia\morphia-core\2.1.4\morphia-core-2.1.4.jar(dev/morphia/
Datastore.class)
[ERROR]     class file has wrong version 55.0, should be 52.0
[ERROR]     Please remove or make sure it appears in the correct subdirectory of the classpath.
[ERROR] /E:/core/src/main/java/me/zoibox/core/core/commands/misc/gamemode/CreativeCommand.java:[12,1] cannot find symbol
[ERROR]   symbol:   static setGamemode
[ERROR]   location: class
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException


quaint mantle
#

show core/src/main/java/me/zoibox/core/core/Core.java

#

and dev.morphia.Datastore

young knoll
#

It doesnโ€™t have a compilation error

#

Itโ€™s a java version error

quaint mantle
#

makes sense

young knoll
#

Oh yeah there is also a cannot find symbol

#

Huh

crude charm
#

hi

#

ok

#

im here

#

ok

#

ill show main class

#

1 sec

#

@quaint mantle

quaint mantle
#

we told you what was wrong

crude charm
#

I tried switching to java 8

#

didnt fix it

#

so I went back to 11

#

didnt fix it

young knoll
#

55 iirc is 11 and 52 is 8

quaint mantle
#

correct

crude charm
#

what is iirc?

young knoll
#

If I recall correctly

crude charm
#

ok

#

but 1.8.0 didnt fix it

#

so...

storm tiger
#
java.lang.IllegalArgumentException: Team  already exists in this scoreboard
``` Not exactly why the team is just empty
quaint mantle
#

bro

crude charm
#

can someone help me... please.

crude charm
quaint mantle
#
if (event.getEntityType() == EntityType.Zombie)
young knoll
#

If that field was ever null Iโ€™d have some questions

quaint mantle
#

lol

deft sedge
#

@quaint mantle I did the part wheryou store the map

#

but how do I check a map for a specific kdywork

#

like if it's already there

quaint mantle
#

containsKey(keyword)

deft sedge
#

thx

#

and then how do I get the uuid of the player listed with that keyword

#

if i find an equal one

real vapor
#

Use Map::get . You'll get null if no value is associated with the key.

deft sedge
#

ok thanks

final fog
#
                for (OfflinePlayer players : Bukkit.getOfflinePlayers()) {
                    Player player = players.getPlayer();``` Could someone help me? the `player` variable is returning null.
real vapor
#

Because they aren't online, so there is no Player object for them

final fog
#

I'm online though

#

Well then

real vapor
#

You're not the only OfflinePlayer

final fog
#

How would I convert an offlineplayer to a Player?

young knoll
#

Iirc you can check isOnline

final fog
#

I want to set something for all of the offline players though.

young knoll
#

You canโ€™t convert an offline player to a player

#

Unless they are online

final fog
#

Dang

#

Alright ill just loop onlinePlayers

deft sedge
#

@real vapor so if the arg has the keyword do i do Map::get arg?

#

or anyone else who wants to answer

young knoll
#

Do map.get(key)

#

And check if itโ€™s null

deft sedge
#

ok

fathom timber
#

Is the only way to get experienced in development like doing it or is there another functional way

young knoll
#

Generally you get experienced in something by doing it

#

Thatโ€™s kind of what the word means

fathom timber
#

True true

deft geode
#

Why is Player#getUniqueId() throwing a NPE

vocal cloud
#

Is player null?

young knoll
#

Yes

deft geode
# vocal cloud Is player null?

this is an a command executor:

Player playerSender;
if(commandSender instanceof Player) {
  playerSender = (Player) commandSender;
} else {
  return false;
}
/* some ... stuff */
trailHandler.setSlotEnabled(playerSender.getUniqueId(), pickedSlot, offOrOn);

And this is in an event listener:

//Event is PlayerInteractEvent
Player sender = event.getPlayer();
if(event.getAction() == Action.LEFT_CLICK_AIR) {
  if(!arrowPowerManager.getActive(sender.getUniqueId())) { //NPE thrown on this line
    return;
  }
}
#

is throws NPE's from both of those statements occasionally

#

but I noticed it mainly rn when I ran the command executed by the above executor

vocal cloud
#

Can I see one of these errors?

deft geode
#

and it threw an NPE when I ran it

#
31.03 20:59:41 [Server] ERROR Could not pass event PlayerInteractEvent to TanoshiCore v1.0.0
31.03 20:59:41 [Server] INFO java.lang.NullPointerException: null
31.03 20:59:41 [Server] INFO at com.chasemw.tanoshicore.eventhandlers.WeaponClick.onClick(WeaponClick.java:31) ~[?:?]
young knoll
#

Should run a newer java version and enable the improved NPEs

deft geode
#

line 31:
if(!arrowPowerManager.getActive(sender.getUniqueId())) {

#

@vocal cloud ^

candid galleon
#

for some reason IntelliJ isn't working with Maven

#
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>xyz.msws</groupId>
    <artifactId>Food</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

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

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.16.5-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

</project>
#

that's my pom xml, but no spigot imports are registering

#

there aren't any errors that I can see

vocal cloud
#

Add a check for it?

deft geode
#

as in the sender variable?

#

thats defined by event.getSender(), which is a playerInteractEvent

#

so why would event.getSender() be null, and what am I supposed to do if it is? don't PlayerInteractEvents only execute when a player interacts>

candid galleon
#

playerinteractevent doesn't have a sender

#

it has a player

deft geode
#

meant to say getPlayer

#

but that's what my code said above

weak adder
#

Hello I am trying to make when a player kills a cow he dies and the cow dosent drop anything! (Killing Cows is illigal)

candid galleon
#

arrowPowerManager is null

deft geode
#

so still, why would getPlayer be null @candid galleon

candid galleon
#

it's probably static or you never initialize it

deft geode
candid galleon
#

can you send the code?

deft geode
#

well its a crapton

#

but

candid galleon
#

?paste

queen dragonBOT
deft geode
#

it's initialized in the main class, and passed via the constructor of the WeaponClick listener

candid galleon
#

can you send the class still?

deft geode
#

which one

#

main class?

candid galleon
#

the one that has the NPE

deft geode
#

k

vocal cloud
#

lmfao

candid galleon
#

and the main?

vocal cloud
#

so it is null

#

It's not static so it sets it on the first instance created but not the next few?

#

Cause when OnClick is called it makes a new instance

#

I bet if you make private final ArrowPowerManager arrowPowerManager; static it will work

deft geode
vocal cloud
#

I thought it didn't?

deft geode
#

it throws the NPE and spams my console, but it fires the arrow

candid galleon
#

can we see the main class?

deft geode
deft geode
vocal cloud
#

But if a new instance is created via the OnClick method then it will be null

candid galleon
#

that's not how java works Mike

vocal cloud
#

Ugh

#

My English

deft geode
#

idk why it says coffeescript

#

whatever

#

its java

vocal cloud
#

When a new instance of WeaponClick is created the OnClick event will be fired and arrowPowerManager will be null

deft geode
#

how is it going to create a new instance of weapon click without passing the arrowPowerManager into the constructor

#

it doesnt

#

there is only one weaponClick object ever, and it's the one I initialize in my main class

#

when I pass it into the event registrar

candid galleon
#

that code should work, are you sure your server is running the most recent build of it?

#

might want to check any duplicate jars too

deft geode
vocal cloud
#

I'm pretty sure I'm right lol

deft geode
vocal cloud
#

Every time the OnClick event is called

deft geode
#

so are you saying it creates a new arrow power manager every single time

deft geode
#

This is the only time an instance of weaponClick is ever created

#

getServer().getPluginManager().registerEvents(new WeaponClick(arrowPowerManager), this);

#

ever

#

spigot literally just goes through the register and executes the events from the passed object

#

it doesn't create a new instance of it?

deft geode
#

this is thrown when i click, still

31.03 21:23:15 [Server] ERROR Could not pass event PlayerInteractEvent to TanoshiCore v1.0.0
31.03 21:23:15 [Server] INFO java.lang.NullPointerException: null
31.03 21:23:15 [Server] INFO at com.chasemw.tanoshicore.eventhandlers.WeaponClick.onClick(WeaponClick.java:29) ~[?:?]
#

as before

candid galleon
#

the WeaponClick class is only 29 lines long

#

the one you sent at least

deft geode
#

line 29 is:
if(!arrowPowerManager.getActive(sender.getUniqueId())) {

candid galleon
#

23*

vocal cloud
#

Doesn't include imports

deft geode
candid galleon
#

id try printing out if the apm is null

#

if it is null then at least you know the problem

deft geode
#

System.out.println(arrowPowerManager == null);

#

prints false

candid galleon
#

ig check player then

#

OH

#

LOL

#

yeah that APM class helps a lot

#

you're returning a Boolean which is an object, meaning it can be null

#

change that to boolean, and return false if the map doesn't contain the id

vocal cloud
#

That'd do it. Is the player ever inserted into the ArrowPowerManager#powerActiveForPlayer

candid galleon
#

better yet change that map to a Set and return true if the set contains that UUID

#

no need for a map

deft geode
#

so this should be better?

    public boolean getActive(UUID id) {
        if(powerActiveForPlayer.get(id) == null) {
            return false;
        } else {
            return powerActiveForPlayer.get(id);
        }
    }
candid galleon
#

return players.contains(id)

#

and Set<UUID> players = new HashSet<>();

deft geode
# candid galleon and `Set<UUID> players = new HashSet<>();`
    public Set<UUID> powerActiveForPlayer;
    public ArrowPowerManager() {
        powerActiveForPlayer = new HashSet<>();
    }

    public void setActive(UUID id, boolean active) {
        if(active) {
            powerActiveForPlayer.add(id);
        } else {
            powerActiveForPlayer.remove(id);
        }
    }

    public boolean getActive(UUID id) {
        return powerActiveForPlayer.contains(id);
    }
candid galleon
#

yep like that

#

id shorten the powerActiveForPlayer name and make it private

#

but other than that looks good

deft geode
#

idk why i made it public

#

IDE suggestions

candid galleon
#

bad IDE

crisp iron
#

https://paste.md-5.net/ogozikimeg.cs

Okay so Im creating world flags now for each world, and for some reason when i add/remove flags the events don't update or anything! Any help is greatly appreciated!

vocal cloud
#

Wait is there only ever one instance of this ArrowPowerManager? Why not make it a static final in some util class instead of having an Object

deft geode
#

Why would that be beneficial? I only want it initialized once, and in the place where all classes can access it

#

Also being able to modify it is helpful

#

In my main class is fine

vocal cloud
#

I mean it doesn't need to be an object unless you're going to have multiple instances of it?

covert urchin
#

I have a Block and I am checking specifically if it is Material.WHEAT. What I'm trying to figure out though is how to find if it is fully grown wheat? I can't seem to figure this one out ๐Ÿ˜ฎ

quaint mantle
covert urchin
#

I have a feeling I need to getMetadata, but IDK what key I'm looking for

crisp iron
#

recommend what? @quaint mantle

candid galleon
#

get the Block's BlockState and cast it to Ageable

quaint mantle
crisp iron
#

i do use enums

covert urchin
#

@candid galleon thanks a lot! I was lost there for a bit not sure what to do. I appreciate the quick reply.

candid galleon
#

๐Ÿ‘

crisp iron
#

i originally had it checking for the enum however it didn't work so I tried different options

quaint mantle
#

I see. Your code looks fine. Yet to find an issue. Any error is console?

quaint mantle
#

avoid when possible

crisp iron
#

none at all, and when i add/remove flags the config updates itself fine. Im so confused why i don't see any update though when i add/remove it player side

quaint mantle
#
if (!new File("plugins/CherryAPI/worlds/" + worldName + ".yml").exists()) {
            this.maxPlayersAllowed = getMaxPlayersAllowed();
            this.worldFlags = new ArrayList<>();
            CherryConfig.createFile("plugins/CherryAPI/worlds/" + worldName + ".yml");
            CherryConfig worldConfig = new CherryConfig(new File("plugins/CherryAPI/worlds/" + worldName + ".yml"));
            worldConfig.loadFile();
            worldConfig.getConfig().set("name", worldName);
            worldConfig.getConfig().set("maxplayers", getDefaultMaxPlayersAllowed());
            worldConfig.getConfig().set("flags", worldFlags);
            worldConfig.saveFile();
            this.worldConfig = worldConfig;
        } else {
            CherryConfig worldConfig = new CherryConfig(new File("plugins/CherryAPI/worlds/" + worldName + ".yml"));
            this.maxPlayersAllowed = worldConfig.getConfig().getInt("maxplayers");
            this.worldFlags = WorldFlag.parseStringList(worldConfig.getConfig().getStringList("flags"));
            this.worldConfig = worldConfig;
        }

You could make this a method.

crisp iron
#

im not worried about my constructors at all @quaint mantle , im more focused on fixing the flags

quaint mantle
#

First thing. Did you register the Listeners?

crisp iron
#

yeah sure did. the only time that i see the updates happen is when i reload the server

#

events work fine, they just don't update when i add/remove the flags

quaint mantle
#

Oh wait

crisp iron
#

i thought about re-registering the events, but i think that would cause too much lag

quaint mantle
crisp iron
#

go ahead,

#

maybe i could understand

quaint mantle
#

it would not work but can you put a println for this getWorldFlagStringList().contains(WorldFlag.NO_ITEM_DROP.getConfigTag()

crisp iron
#

okay

#

so

#

i inserted that code in the blockplace event, and changed the enum to match, and it returns false. HOWEVER the world does have that flag added, but it returns false instead.

quaint mantle
#

Config was saved correct?

crisp iron
#

yes

#

it's as if it's opposite

#

so maybe i need to just put ! in front and go with it? xD

#

that did not fix it lmao

#

WTF xD

quaint mantle
#

If you really wanted to. Print out what is in config so you can see if it has the flag.

crisp iron
#

oh!

#

okay!

#

i got it, so, it's retrieving an empty list XD

#

sooo, what the issue was it was retrieving the flags list as a string list (which it wasn't) and that's why it was empty. So i have to change the method when it retrieves the list to fix the issue

#

then it should be good

quaint mantle
#

Perfect!

crisp iron
#

it was a good thing i went ahead and condensed my code too while i was waiting for your input now it should hopefully work

quaint mantle
#

๐Ÿ’ฏ Glad to help.

crisp iron
#

alright, still no fix. The list is printing correctly though now and it is checking correctly. However the event doesn't want to work as soon as the flag is added/removed

wet breach
#

File("plugins/CherryAPI/worlds/" + worldName + ".yml") stick this into a variable @quaint mantle

#

second, you are checking files incorrectly

#

it should this
File("plugins/CherryAPI/worlds/", worldName + ".yml");

#

notice I changed a + to a ,

crisp iron
#

it does the same thing but yeah okay

#

that is not my issue

wet breach
#

yes and no

crisp iron
#

im still having my issue with the events not just updating

wet breach
#

you don't have to, but helps with making it look nice/readable

#

also helps with not making a mistake for the same directory since you can have it defined in just one place

#

and I pinged the wrong peron @quaint mantle

#

sorry just woke up

#

@crisp iron can we see the code for the config update stuff?

quaint mantle
#
public class NOITEMDROP extends ServerCherryListener {

        public NOITEMDROP() {
            super(worldName + "_NOITEMDROP", false);
            worldFlagEvents.add(this);
        }

        @EventHandler
        public void event(PlayerDropItemEvent event) {
            if (getWorldFlagStringList().contains(WorldFlag.NO_ITEM_DROP.getConfigTag())) {
                Player player = (Player) event.getPlayer();
                if (!player.hasPermission("cherryapi.flag-override")) {
                    System.out.println("THIS WORKS RIGHT?");
                    event.setCancelled(true);
                    new OnlinePlayer(player).sendColorfulMessage(ServerAPI.getAPI().getBasicMessages().getString("itemdrop-disabled"));  
                }      
            }
        }
`
    }

add this debug

#

@crisp iron

#

lol you need a bang or a Redbull

wet breach
#

I agree with you in aoviding duplicity where you can

#

as well

#

have a monster energy drink

#

just waiting for it to kick in

#

XD

crisp iron
quaint mantle
#

LOL its like 10:28 way to late for me

crisp iron
#

that is the add/remove method in my worldmanager

#

it saves

wet breach
#

is the worldmanager called WorldConfig?

crisp iron
#

called WorldManger

quaint mantle
#

Looks fine to me. Can you add the debug and tell us if it works.

wet breach
#

be nice to see where you set worldConfig? since you are complaining of configs not updating

quaint mantle
#

He said it saves btw

quaint mantle
crisp iron
#

yeah it does

#

that part im confident in and i checked everytime i add/remove flags

wet breach
#

Ok then what issue you having where you say events are not updating? o.O

quaint mantle
crisp iron
#

so say i remove block place event, you still can't place blocks as if it didn't update. but then when i reload the server it's fine.

wet breach
#

that doesn't really make sense. So you remove the event from your code for example right? And it still doesn't let you place blocks even though you are not touching the event?

crisp iron
#

exactly

wet breach
#

I assume you are using a variable to check this?

#

or you just straight up commented out your code?

quaint mantle
#

@crisp iron are you OPed on the server?

crisp iron
#

no

wet breach
#

This sounds like a case of you updating your plugin and assuming that if you replace the jar, the server should have updated code. When in fact you need to restart the server because all class files in jar gets loaded into the server and doesn't update without some tool to force it to do so or just restart since you know everything unloads then XD

quaint mantle
#

try that and also put a debug after the check for permission.

crisp iron
#

just so were clear, everytime that i've put the new jar in i've had to restart, im using maven so there really isn't any other way

#

so that's not the issue

wet breach
#

Yes that is completely normal to do that. So not the issue then alright just had to make sure lol

#

be surprised in how many people assume their code should automagically update XD

crisp iron
#

yeah i'd see where that can be an issue

#

but like maven has a complete and seperate output

#

rather than looking at the itemdrop event that i have look at my block place event (that's what i've tested on the most)

wet breach
#

is your project open source?

crisp iron
#

it is and it isnt

wet breach
#

guess that works lol

crisp iron
#

that is an updated version of the class we've worked on

wet breach
#

Should avoid using statics if you don't need them just fyi

#

still looking at it

quaint mantle
#

static abuse

wet breach
#

well they don't abuse it like others do so I will commend them on that

crisp iron
#

i cannot lie, i've tried my best to avoid statics entirely

#

but sometimes i just slip up

quaint mantle
#

Static is not a bad thing to use. You just gotta use it properly.

crisp iron
#

anywho, i realized that when i called for the list "getWorldFlags()" and then print it it doesn't update

#

so that's now an issue

#

it is the issue

wet breach
#

anytime you can possibly have empty lists/null's returned, have some kind of check to inform when this is possibly not what is wanted.

#

in fact

crisp iron
#

well heres the thing, it isn't returning null it's printing a list, but it's not getting the updated list from the config (idk why) cause there's where i pull it from

wet breach
#

change that to reference your variable at top

#

well, you reference the variable flags in two different ways

#

so, maybe if we fix it in your code to be just at a singular place maybe that might fix it

crisp iron
#

i hate to doubt, but i really don't think its the issue

wet breach
storm tiger
#

When removing metadata does the player actually need the metadata to try to remove it?

wet breach
#

@storm tiger generally wise to put a check in place so you are not just running code unnecessarily

storm tiger
#

looks like removeMetadata already checks if they have it

wet breach
#

sometimes it will throw a minor error if you are trying to remove non-existent metadata but it really depends how you are doing it.

crisp iron
#

swapped exactly with which line

wet breach
#

101

#

the one right above it

#

whether the file exists or not isn't relevant to the file Object. Should create your object first and then check if said directory/file it holds actually exists, create if it isn't.

crisp iron
#

i go a bit further with it for the API to create customization

wet breach
#

Well its not a typical thing to see most of the time ๐Ÿ˜›

#

it is fine you have your own objects like that if it makes things more convenient ๐Ÿ™‚

crisp iron
#

yeah i even have a custom command class

#

allows the ability to create your own help page

#

like for each command

wet breach
#

btw I used the wrong line number earlier

crisp iron
#

it's "hella" advanced, not advanced, just much more convenient

wet breach
#

but line 102 might be where your problems are at for the flags

sage swift
#

whyyy does Recipe not have getKey

crisp iron
#

if i swapped the lines that your talking about it would just throw an error when creating / loading in new worlds

wet breach
#

so, that method should reference your flags object that is up top. In the constructor where you initialize it is where you would update said object. To prevent accidentally NPE's you can go ahead and move the arrayList creation to the top so at minimum it will return an empty array if something calls for it too early

#

private List<WorldFlag> worldFlags = new ArrayList<>();


    /**
     * Returns world flags
     * @return
     */
    public List<WorldFlag> getWorldFlags() {
        return this.worldFlags;
    }

    /**
     * Initialize config
     */
    public void initialize(String worldName) {
        this.worldName = worldName;
        this.permissionAccess = WorldManager.accessPermission + worldName;
        this.worldFlagEvents = new ArrayList<>();
      this.getWorldFlags().addAll(WorldFlag.parseStringList(this.worldConfig.getConfig().getStringList("flags")));
        this.isLoaded = false;
        this.eventsLoaded = false;
        this.worldConfig = new CherryConfig(new File("plugins/CherryAPI/worlds/" + worldName + ".yml"));
        if (!new File("plugins/CherryAPI/worlds/" + worldName + ".yml").exists()) {
            this.maxPlayersAllowed = getMaxPlayersAllowed();
            CherryConfig.createFile("plugins/CherryAPI/worlds/" + worldName + ".yml");

            this.worldConfig.loadFile();
            this.worldConfig.getConfig().set("name", worldName);
            this.worldConfig.getConfig().set("maxplayers", getDefaultMaxPlayersAllowed());
            this.worldConfig.getConfig().set("flags", WorldFlag.convertToConfigList(worldFlags));
            this.worldConfig.saveFile();
            this.worldConfig = worldConfig;
        } else {
            this.maxPlayersAllowed = worldConfig.getConfig().getInt("maxplayers");
            this.worldConfig = worldConfig;
        }
    }
#

ok, contains all the fixes so as to use your getter, as well as removed the redundant creation of worldConfig object

crisp iron
#

okay im gonna try this

wet breach
#

You have worldConfig up at the very top already declared, doesn't make much sense in the initializing phase, to create another worldConfig object. Mainly because you are wanting to set the global variable, not the method local one.

#

Should fix your problem since you had that duplicate worldConfig going on. The one in the method, was not updating your global one

#

but your global wasn't being updated because it was fetching from the config file which happened on startups

#

hence why restarting made it update

storm tiger
#

How come on toggle flight event if i cancel turn their allow flight off and flying off and give them a little push they just start going down

wet breach
#

because the server updated their state since something interacted with them

storm tiger
#

like what though

wet breach
#

the player object state. Server doesn't immediately make them fall because it isn't always checking if the block they are on is air or not until they start moving

#

since you pushed them, they moved

#

thus now the server checks the block under them and goes, oh yeah its air so start falling now

storm tiger
#

anyway to just like bypass that?

#

im setting velocity

#

so shouldn't it keep going up until the motionY is 0?

wet breach
#

don't understand that last part o.O

storm tiger
#

yeah i dont either tired

#

but

#

its like im getting teleported down, but whenever i use like an ender pearl that sets velocity instead of throwing it the velocity works perfectly but once i check for them toggling their flight it just bugs and starts trying to teleport them down

wet breach
#

so the ender pearl, is custom correct?

#

and instead of teleporting it sets a velocity?

crisp iron
#

testing now, i had a few NPE's but they are fixed

wet breach
#

Ah my bad if that was my fault lol

storm tiger
crisp iron
#

still no fix

wet breach
#

o.O

#

really @crisp iron ? It should have updated the list just fine

storm tiger
#

hmm something is setting off teleport event whenever doing that

crisp iron
#

yeah it's weird

wet breach
#

That was really the only place where I saw duplicate object creation lol

#

make sure to remove these lines this.worldConfig = worldConfig; as well

#

not needed since you are just referencing a singular object and updating that. And everywhere else should be referencing the getter outside of the initializing method

#

@storm tiger it could be the fact that the player object is kind of in limbo when they are hovering in the air like that. If they toggle their flight, either toggle it back on before doing your thing, or do something to update their state first.

crisp iron
#

i have the code exactly like you suggested (with the exception of a few changes to fix the NPE's i was getting)

wet breach
#

interesting, could have sworn that would fix your lists not updating properly o.O

#

I would start adding some debug messages @crisp iron

#

so after every thing you are doing manipulating the list in all your code just have it print out what it just did as well as what the list looks like.

crisp iron
#

im just going to use a hashmap

#

and store the list when the world is first initialized, then at the end save all the lists.

#

@wet breach

wet breach
#

that could work. But I believe you should probably resolve the issue first before making drastic changes

crisp iron
#

not to bad of a drastic change honestly.

wet breach
#

otherwise you won't gain the experience/knowledge in why it wasn't working to begin with

#

meaning if you encounter this issue again, you wouldn't know where to possibly start checking for problems since you didn't bother resolving a similar issue. However, it is up to you which you want to do though.

#

Just my personal opinion is all. Second it is good to get into the habit of being able to create debug messages too

#

this won't be the only time you encounter such a problem where it isn't obvious on the problem

#

Debug messages help you narrow down where an object isn't being updated properly so you know which methods are possibly responsible, instead of not having a clue since a lot of things touch it.

outer sorrel
#

im using a packet listener for getting when the player moves but how would I make a way to get the players previous position?

wet breach
#

the PlayerMoveEvent has a method of getting where they moved from

#

and another method to get where they moved to

#

first one is the method for getting where they moved from. AKA previous location, second is to get the location where they moved to ๐Ÿ™‚

#

oh packet listener

#

why are you using a packet listener for this?

#

You are just going to have to keep track of the players previous positions yourself if you are going to go the packet route @outer sorrel which isn't really necessary since there is events that get triggered for this and API methods to help with it.

outer sorrel
#

doing packet stuff

wet breach
#

Ok

outer sorrel
#

ill try to use the move event then

wet breach
#

why does that mean you can't use the API?

outer sorrel
#

theres no getFrom()

wet breach
#

There is in the API

#

If you are going to try and use both the event and packets

#

then you will need to have your packet listener wait on the event to complete which there you would use a custom object that your packet listener can then use. Personally I would only use packets if its really necessary. Most of the time, it isn't always more efficient to just manipulate packets then to just manipulate events.

outer sorrel
#

ok thanks

spring fog
#
event.getClickedBlock().getLocation() == button.getLocation()

So, these are the same location, yet the boolean is still false. confusion

quiet ice
#

Oh no

#

Look at the operator again, then question your life choices

#

Spoiler: ||they are not the absolutely same location like == would suggest, they may differ in the memory location, == only checks for the memory location||

spring fog
#

okay then

#

how can i check if the block that i clicked is the same block that im trying to refer to

#

presumably id use locations?

quiet ice
#

Seriously, have you used java before?

#

If only there was a method that does this, it's not like it's nicely named ||Object#equals(Object)||

spring fog
#

There is absolutely no reason to be rude when I'm asking questions based around development, the entire point of this channel. Yes, I know Java and have been developing with it for the past two years. Simply put, I misread the first 'spoiler' you gave.

quiet ice
#

Basically, only use == for Enums, Integers, Doubles, Floats, Chars, Interned Strings (they are almost never interned), Shorts, Longs and a few other rare occasions, Object#equals(Object) should be used for anything but primitive types (in which case it will not even compile)

spring fog
#

Thank you, that does help ๐Ÿ™‚ Sometimes I forget the difference

alpine swan
quiet ice
kindred solar
#

Guys, im trying to do a database, should i do a local or one with sql?

quiet ice
#

SQL can be local, but it is recommended that the database should be as near to the server as possible (preferably on the same machine)

opaque mango
#

Integer and other primitive wrapper classes have some instances cached, but not all

#

most of the time, using == for them is just as bad as using == for Bukkit Locations

quiet ice
#

I would need to look into that

opaque mango
#

yes, you would

quiet ice
#

But I am fairly sure that this hasn't blown up yet and I have worked with boxed integers for a while now

opaque mango
#

:thonk:

quiet ice
#

Ight, time to decompile some bytecode!

opaque mango
#

or just look at the documentation?

#

looking at bytecode is a terrible idea, as you might discover implementation details that can change in the future

#

even comparing Boolean instances via == is a programmer mistake

#

that was a fun bug to debug

quiet ice
#

.code stack 2 locals 3
L0: ldc '1000'
L2: invokestatic Method java/lang/Integer valueOf (Ljava/lang/String;)Ljava/lang/Integer;
L5: astore_1
L6: aload_1
L7: invokevirtual Method java/lang/Integer intValue ()I
L10: sipush 1000
L13: if_icmpne L24
L16: getstatic Field java/lang/System out Ljava/io/PrintStream;
L19: ldc 'sssss'
L21: invokevirtual Method java/io/PrintStream println (Ljava/lang/String;)V

    .stack append Object java/lang/Integer 

L24: sipush 1000
L27: istore_2
L28: iload_2
L29: sipush 1000
L32: if_icmpne L43
L35: getstatic Field java/lang/System out Ljava/io/PrintStream;
L38: ldc 'sssss'
L40: invokevirtual Method java/io/PrintStream println (Ljava/lang/String;)V

#

they are the same thing, javac isn't that stupid

#

Basically, it auto-unboxes it automagically; while sure, it is an implementation detail, it can almost be guaranteed that it will stay that way because it would simply break too many applications otherwise

opaque mango
#

do you use Eclipse?

#

no wonder you make these mistakes

quiet ice
#

No, normal javac

opaque mango
quiet ice
#

This was written without any IDE

opaque mango
#

congratulations

quiet ice
#

Then disassembled via Krakatau

opaque mango
#

congrats, you reached the wrong conclusion though

quiet ice
#

So basically as long as only one operator is primitive it will auto-unbox

opaque mango
#

yes

weary geyser
#

Is it possible to generate a method when you annotate something?

opaque mango
#

yes

weak adder
#

Hey how do I make a specific mob invincible/not killable

weary geyser
opaque mango
quiet ice
#

It probably has to do that I only work with small numbers I guess, but I suppose it is good to know for the future

opaque mango
#

I literally sent you a tutorial

#

what more do you want?

weak adder
#

Hello can someone pls help me
Hey how do I make a specific mob invincible/not killable

sullen marlin
weary geyser
#

It shows you the basics of annotation processors

opaque mango
opaque mango
quiet ice
#

That is JVM specifics though

weary geyser
quiet ice
#

It is best to know it for use if you look at the disassembled code (two boxed integers use acompare, if one is not boxed then it uses icompare instead)

weary geyser
#

what point

quiet ice
#

Alternatively you could look at how Lombok does it @weary geyser

sullen marlin
#

lombok is a mess, dont copy lombok

opaque mango
quiet ice
#

I mean, it works

daring sierra
opaque mango
#

That articles creates a separate source file. Do you want to edit an existing sorce file?

quiet ice
#

Better than doing asm magic

weak adder
opaque mango
weak adder
quiet ice
#

Source processing iirc

#

So pre-compile time

wide galleon
#

How can I make a command that doesnt get send to the console when executed?

quaint mantle
#

hey how do i get like all rows but get only one data? like i have (name, uuid, etc.) and i only want to get name from every row.

#

?paste

queen dragonBOT
quaint mantle
#

Currently my code: https://paste.md-5.net/abolawebiz.cpp
Only gives me an error for:

java.sql.SQLException: Column Index out of range, 0 < 1.
[11:27:39 WARN]:        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
[11:27:39 WARN]:        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
[11:27:39 WARN]:        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
[11:27:39 WARN]:        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
[11:27:39 WARN]:        at com.mysql.jdbc.ResultSetImpl.checkColumnBounds(ResultSetImpl.java:812)
[11:27:39 WARN]:        at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5657)
[11:27:39 WARN]:        at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5576)
[11:27:39 WARN]:        at pavlyi.authtools.listeners.ImportHandler.importYAML(ImportHandler.java:53)
[11:27:39 WARN]:        at pavlyi.authtools.commands.AuthToolsCommand.onCommand(AuthToolsCommand.java:259)
[11:27:39 WARN]:        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
[11:27:39 WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
[11:27:39 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641)
[11:27:39 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627)
[11:27:39 WARN]:        at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412)
[11:27:39 WARN]:        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375)
[11:27:39 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654)
[11:27:39 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557)
[11:27:39 WARN]:        at java.lang.Thread.run(Unknown Source)
wet breach
opaque mango
#

I think even geolyct understands that now, no need to bring it back up

tiny mountain
#

Hey guys i have a problem ...
Im trying to spawn a rainbow sheep but can't figure it out can you help me please ?

Sheep rainbowsheep = (Sheep)block.getWorld().spawnEntity(block.getLocation(), EntityType.SHEEP);
            BukkitTask runnable = new BukkitRunnable() {
                int colors = 16;
                @Override
                public void run() {
                    colors -= 1;
                    rainbowsheep = block.getWorld().spawn(block.getLocation(), Sheep.class);
                    rainbowsheep.setCustomName("ยงaSยงbpยงcaยงdlยงevยงfoยงatยงba ยงfavis!");
                    rainbowsheep.setCustomNameVisible(true);
                    rainbowsheep.setColor(DyeColors[colors]);
                    if (colors == 1) {
                        colors = 16;
                    }
                }
            }.runTaskTimer((Plugin) this, 20L, 20L);
#

this line in particular :

rainbowsheep.setColor(DyeColors[colors]);
#

Idk how can i convert a int to a DyeColor ?

wet breach
#

by not using int to begin with and just use Color

quaint mantle
#

i dont think so you can use int

opaque mango
#

Jesus wants to iterate through colors, he can choose to store an int or store a color and make indexof calls

wet breach
#

there isn't a method in the API to go from int to a color. Would have to map the numbers yourself and keep track of it.

#

or you can use byte data

#

but that is deprecated

tiny mountain
opaque mango
#

DyeColor is an enum, it can be enumerated in order

#

so the issue isn't with the integer variable

wet breach
#

Yes that is correct forgot that, in this case you could just simply iterate over the enum itself

tiny mountain
#

Well the other solution i have is to set the name to jeb_

#

but i can't hide it eaven with setCustomNameVisble(false)

opaque mango
#

he wants delays between the different colors, that's why iterating over the enum is not a good option

wet breach
#

not sure why the delay means you can't

#

but anyways, I will show you an example where you don't even need to bother with ints at all

opaque mango
#

he currently iterates over the enum values through indexes, which is a valid concept

wet breach
#

never said it wasn't

wet breach
#

that isn't me saying it isn't a valid concept

#

so please sush and stop spreading mis-information in what I have stated

opaque mango
#

lol

#

he got the basic concept of how to achieve the task, why do you want to change that?

wet breach
#

obviously they are having difficulty in translating from integer to colors. If that is the case, why not show a way that just removes the confusion all together o.O

#

However, I tend to show more then one way of doing something as well

#

Anyways its fine I will just go do something else if you have such a problem with people showing examples of different ways of doing something ๐Ÿ™‚

opaque mango
#

I don't know why you care about me so much

#

you do whatever you want

wet breach
#

I don't you are the one commenting on everything I have said thus far, and I have only responded

opaque mango
#

you are the one who pinged me originally about an old and finished conversation, so I stayed for a bit afterwards

wet breach
#

Yes originally and then I moved on

#

as I said, its completely fine I don't have to help people if others have a problem with it

opaque mango
#

are you butthurt?

wet breach
#

doesn't change the facts

opaque mango
#

whatever, I'll go and help him, best I would do is tell him to learn java

#

*I'll go and you help him

wet breach
#

you also learn by others teaching

#

๐Ÿ™‚

opaque mango
#

ain't got no interest in spoonfeeding people who don't know java basics

wet breach
#

and this is why you don't teach which is completely fine ๐Ÿ˜‰

#

@tiny mountain give me a bit to finish eating and I will help you out

tiny mountain
#

Alright ty sir

ivory sleet
#

Yo pro coders

quaint mantle
#

hey does anybody know how can i get a data from every row in MySQL ?

#

or like a list of row

#

nevermind got it.

wet breach
#

You pretty much had it with the way you did it, just was missing the array and I moved your minus of the numbers to the bottom as well as changed it since it isn't necessary to set the variable specifically since we don't use any different objects for it. Changed the int to get the size of DyeColors array. Just removes so called magic numbers. Also changed which number to check to start over as well as the maximum. Arrays start at 0.

Sheep rainbowsheep = (Sheep)block.getWorld().spawnEntity(block.getLocation(), EntityType.SHEEP);
            BukkitTask runnable = new BukkitRunnable() {
                int colors = DyeColor.values().size();;
                DyeColor[] dyes = DyeColor.values();
                @Override
                public void run()
                    rainbowsheep = block.getWorld().spawn(block.getLocation(), Sheep.class);
                    rainbowsheep.setCustomName("ยงaSยงbpยงcaยงdlยงevยงfoยงatยงba ยงfavis!");
                    rainbowsheep.setCustomNameVisible(true);
                    rainbowsheep.setColor(dyes[colors]);
                    if (colors == 0) {
                        colors = DyeColor.values().size();
                    } else {
                        --colors;
                    }
                }
            }.runTaskTimer((Plugin) this, 20L, 20L);

was going to show you another way, but this should be sufficient @tiny mountain

#

there had to fix it, don't want to minus colors just right after it gets reset ๐Ÿ˜›

tiny mountain
wet breach
#

what issue are you having?

tiny mountain
#

Dyecolor can't be resolved

wet breach
#

ah should be DyeColor

#

And it should resolve it

#

if not, just add import org.bukkit.DyeColor

#

should be at the top with the rest of the imports

tiny mountain
#

i have the import and copy pasted ur code but still not

wet breach
#

I fixed the above to remove the s on DyeColor since it isn't plural lol

#

Also, I assume the issue is in the if check right @tiny mountain ?

#

if so, the c in DyeColor needs to capitalized, mistake on my part which I also fixed in the above to reflect that XD Never assume that code given will always 100% work straight away. We all make simple mistakes like I did.

tiny mountain
#

alright wait

#

Almost everything is good

#

it just can't Invoke size() on the array type DyeColor[]

wet breach
#

try using getSize() instead

#

don't have my IDE opened so I forget which is appropriate since some collections uses size() and others getSize() lol

tiny mountain
#

alright

#

there is not size or get anything

wet breach
#

o.O

lost matrix
minor garnet
#

https://paste.md-5.net/etuhaqasip.java

[15:07:14 WARN]: org.apache.commons.lang.UnhandledException: Plugin Arma v1.0 generated an exception while executing task 80
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.ConcurrentModificationException
        at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:911)
        at java.util.ArrayList$Itr.next(ArrayList.java:861)
        at vinnydgf.arma.Arma.tick(Arma.java:29)
        at vinnydgf.arma.Arma$1.run(Arma.java:55)
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71)
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
        ... 3 more```
lost matrix
minor garnet
#

wait

#

?paste

queen dragonBOT
wet breach
#

@lost matrix lol thanks

#

@tiny mountain as stated above, use length() instead XD

lost matrix
wet breach
#

or when you don't have your IDE, it just makes more sense to call it size()

#

and not length()

minor garnet
#

๐Ÿ‡ซ

tiny mountain
#

@wet breach ok thanks

minor garnet
#

Adelemphii i have a dark theme, but the window is white

ancient plank
#

it hungers

quaint mantle
#

Can I get number of online players from Bungeecord as int? From spigot plugin?

lost matrix
tiny mountain
#

So the code compile
But spam errors in console on event and the sheep is normal

Sheep rainbowsheep = (Sheep)block.getWorld().spawnEntity(block.getLocation(), EntityType.SHEEP);
            BukkitTask runnable = new BukkitRunnable() {
                int colors = DyeColor.values().length;
                DyeColor[] dyes = DyeColor.values();
                @Override
                public void run() {
                    rainbowsheep.setCustomName("ยงaSยงbpยงcaยงdlยงevยงfoยงatยงba ยงfavis!");
                    rainbowsheep.setCustomNameVisible(true);
                    rainbowsheep.setColor(dyes[colors]);
                    if (colors == 0) {
                        colors = DyeColor.values().length;
                    } else {
                        --colors;
                    }
                }
            }.runTaskTimer((Plugin) this, 20L, 20L);
quaint mantle
#

if (subchannel.equals("SomeSubChannel")) - What i should write in SomeSubChannel?

lost matrix
eternal oxide
tiny mountain
#

N ?

lost matrix
tiny mountain
#

So where is my error ?

vague mason
#

DyeColor.values().length -1;

lost matrix
# tiny mountain So where is my error ?

You are trying to access the array with an index that is equal to its length. So this will throw a ArrayIndexOutOfBoundsException.
Think about where your index is too big and change it to a fitting value.

lost matrix
tiny mountain
#

well i tryed but i still get the same error

vague mason
#

int colors = DyeColor.values().length -1;

#

or rainbowsheep.setColor(dyes[colors - 1]);

lost matrix
vague mason
#

you do the same mistake here too

vague mason
tiny mountain
#
Sheep rainbowsheep = (Sheep)block.getWorld().spawnEntity(block.getLocation(), EntityType.SHEEP);
            BukkitTask runnable = new BukkitRunnable() {
                int colors = DyeColor.values().length-1;
                DyeColor[] dyes = DyeColor.values();
                @Override
                public void run() {
                    rainbowsheep.setCustomName("ยงaSยงbpยงcaยงdlยงevยงfoยงatยงba ยงfavis!");
                    rainbowsheep.setCustomNameVisible(true);
                    rainbowsheep.setColor(dyes[colors-1]);
                    if (colors == 0) {
                        colors = DyeColor.values().length-1;
                    } else {
                        --colors;
                    }
                }
            }.runTaskTimer((Plugin) this, 20L, 20L);
            break;
#

so the out of bounds is fixed here right ?

lost matrix
#

dyes[colors-1] -> dyes[colors]

tiny mountain
#

okay

#

and then it's good ?

lost matrix
#

probably

tiny mountain
#

sadly no

lost matrix
#

What exception do you got?

tiny mountain
#

well let me past it

lost matrix
#

(Plugin) this
Thats not possible. You need to pass an instance of your JavaPlugin class.
You can not randomly cast one class to another.

tiny mountain
#

Well i guess i will take more time to learn java i will get back once i have a better base

quaint mantle
#

I use the same code on PlayerJoinEvent (which works fine) on respawn it does nothing. Any reason on why ? The item in question also gets removed on player death with List.remove.

quaint mantle
#

Ah player does not get item on respawn event

lost matrix
quaint mantle
#

I'll check the api if I can point player to the exact player. I'm fairly new x)

drifting halo
#

e.getPlayer()

lost matrix
# quaint mantle I'll check the api if I can point player to the exact player. I'm fairly new x)

Because you are setting the item for one player N times the amount of other players on the server.
This would be a cleaner refactoring for your event:

Player player = event.getPlayer();
if(!player.hasPermission(...)) {
  return;
}
FileConfiguration config = Gat.plugin.getConfig();
if(!config.getBoolean(...)) {
  return;
}
boolean isFloodGatePlayer = CheckJavaOrFloodPlayer...;
if(!isFloodGatePlayer) {
  return;
}
ItemStack netherStar = new ItemStack(Material.NETHER_STAR);
ItemMeta ... etc
player.getInventory().setItem(config.getInt("Slot"), netherStar);
crude charm
#
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project Core: Fa
tal error compiling: invalid target release: 11 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

lost matrix
crude charm
#

I do

lost matrix
#

Open a terminal and type java -version pls

crude charm
#

E:\core>mvn clean installjava -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Program Files\apache-maven-3.6.3\bin..
Java version: 1.8.0_212-release, vendor: JetBrains s.r.o, runtime: C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\jre64
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

E:\core>

lost matrix
#

Open a terminal and type java -version pls
Then send a screen

crude charm
lost matrix
#

You got a 1.8 jre thats not even up to date.

crude charm
#

I dont have it in the folder

#

like

#

how

#

just

#

how

cinder thistle
#

@ivory sleet currently trying to use morphia with all modules. Either I can strictly restrict morphia to oxide-common or I can use it across all modules. I'm thinking the first one is the better idea to keep components seperate.

I pinged you because anybody else would have no idea what I'm talking about.

Actually in other news I need Sentry for all modules and I don't wanna do it for every single module, how would I do that?

crude charm
#

this was happening before

#

I dont understand

#

how

lost matrix
crude charm
#

intelliJ terminal

#

or cmd

lost matrix
#

Try both and see if there is a difference

crude charm
lost matrix
#

You dont even have any properly installed java version at all

crude charm
lost matrix
#

Oh and there is the jre 1.8 again

crude charm
#

I want to know where it is installed

#

cause idk

lost matrix
#

Just download the latest jdk and install it.

crude charm
#

I did

#

and

#

doesent work

wet breach
#

@lost matrix Java doesn't use JAVA_HOME anymore and if I recall no longer sets that variable

lost matrix
wet breach
#

It uses symlinking and adds the path to the symlink in path environment variable instead of maintain its own environment variable

#

this way, when it needs to be updated, all that gets changed is the symlink and nothing needs to be done with the path

cinder thistle
#

o

#

that explains a lot

crude charm
#

installing 16 rn

lost matrix
crude charm
#

how

#

it might be that

lost matrix
#

File > Project Structure

wet breach
#

However I added JAVA_HOME because unfortunately, maven still requires it XD