#TitleAPI help

1 messages · Page 1 of 1 (latest)

sinful rain
reef cedar
#

hello

sinful rain
#

yo

reef cedar
#

i dont see im here in the console

#

i see a error

jovial hedge
#

which error?

reef cedar
#

Could not pass event PlayerJoinEvent to gabby128bit v2.0

jovial hedge
#

thats not the whole thing

reef cedar
jovial hedge
#

it cannot find the api thing

reef cedar
#

how i resolve it?

sinful rain
#

is titleapi a plugin

reef cedar
#

not an api?

jovial hedge
reef cedar
#

it's this

sinful rain
reef cedar
sinful rain
#

oh wait

reef cedar
#

okay

sinful rain
#

its until 1.17

#

it says

reef cedar
#

OHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

#

IM FUKING STUPID

sinful rain
#

chill that shouldnt be the issue

#

lmao

jovial hedge
#

if something has an onEnable method , does it makes that a plugin? @sinful rain

sinful rain
#

i think youre not loading it as a plugin

sinful rain
#

technically

reef cedar
#

i test on 1.17

jovial hedge
#

ye then this is a plugin

sinful rain
reef cedar
#

Ok

sinful rain
#

the server needs to load it for your plugin to work

#

basically the error is telling you that it cant find a part of TitleAPI, in this case the entirety of TitleAPI

#

which means you have to load it somehow

#

which is usually done through (1) loading it as a plugin if possible, or (2) shading the library into the plugin (putting the dependencies into the jar)

#

read that

reef cedar
#

ok

#

IT WORK'S YEAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

#

i have other problem

jovial hedge
#

what?

reef cedar
#

how do i make a plugin where no player can break blocks in the map?

jovial hedge
#

listen for the block break event and cancel it

reef cedar
#

oh tank you

#

I've been trying for a month to do something but I can't

#

I'm trying to do the compass that teleports to other worlds

#

now I send the code that I have done so far

#

in the main i put this:
Bukkit.getServer().getPluginManager().registerEvents(new PlayerInteract(), this);

in the PLayerInteract event i put this:

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

public class PlayerInteract implements Listener {
    @EventHandler
    public void onInteract(PlayerInteractEvent event) {
        Player player = (Player) event.getPlayer();

        if(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
            if(player.getItemInHand().getItemMeta().getDisplayName().equals("MODALITA")) {
                Inventory inv = Bukkit.createInventory(null, 27, "MODALITA");


            }

        }

    }
}```


In the on player join event i put this:
```ItemStack item = new ItemStack(Material.COMPASS);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("MODALITA");
        item.setItemMeta(meta);
        player.getInventory().clear();
        player.getInventory().setItem(1, item);```
#

help?

#

Plssss

jovial hedge
#

so open the inventory for the player i guess?

jovial hedge
#

open the inventory and then listen for a possible inventory click event, check the slot and compare it with the slot where the compass is in, if it maches do a teleport thing

reef cedar
#

ok

#

and for the block break event i maked a fail

#

i dont know how to disable

jovial hedge
#

you made a fail? what do yo mean

#

are you trying to add a bypass?

reef cedar
#

@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
event.setCancelled(true);
}
}

#

it's correct?

jovial hedge
#

ye it will not allow anyone to break a block

reef cedar
#

Cannot resolve method 'setCancelled' in 'BlockBreakEvent'

#

i fixed it

#

the plugin don't work

#

i can break all

#

RIP

#

you can help me?

#

@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
event.setCancelled(true);
}

jovial hedge
#

are you sure you registered the event?

#

are there other plugins which override the cancelling of the event?

reef cedar
jovial hedge
#

then normally it should work

reef cedar
#

😦

#

not work

#

RIP

#

I GET BANNED ON GTA

reef cedar
#

i fixed the plugin

#

but i dont know how to make the compass

#

and instead if I wanted that only the blocks of the map cannot be broken but those that place the players can be broken, can it be done?

#

??????????

reef cedar
#

hello

jovial hedge
#

The most simple solution would be giving the players wool or something to build with and only allow wool to je broken

sinful rain
#

or store a hashset of locations players have placed blocks

#

and check if it contains it

#

when you break

#

or the other way around; a hashset of blocks in the map

#

that shouldnt be brokne

#

broken

reef cedar
#

nooooooooooooooooooooooooooooo

#

i want to make players block broken = true
and i want to make players block broke with hand or tools

jovial hedge
#

You want to make players can break blocks?

reef cedar
#

player can break players block

#

and not default map blocks

jovial hedge
#

you're not properly explaining what you're trying to do

reef cedar
#

i want to make players can break block but not the map block

map block = blocks of the server

jovial hedge
#

we explained you how to do it the best way

reef cedar
#

BRUH

reef cedar
jovial hedge
#

store a set of locations of blocks the players have placed

#
Set<Location> locations = new HashSet<>();


@EventHandler
void onBlockBreak(BlockBreakEvent event) {
  if (!locations.contains(event.getBlock().getLocation())) {
    event.setCancelled(true);
  }
}
@EventHandler
void onPlace(BlockPlaceEvent event) {
  locations.add(event.getBlock().getLocation()); // set prevents duplicates
}
``` smth like that
sinful rain
#

yeah

#

exactly

#

maybe remove them when broken

#
Set<Location> locations = new HashSet<>();

@EventHandler
void onBlockBreak(BlockBreakEvent event) {
  Location loc = event.getBlock().getLocation();
  if (!locations.contains(loc)) {
    // is not a block placed by player
    event.setCancelled(true);
  } else {
    // is a block placed by player
    locations.remove(loc);
  }
}
@EventHandler
void onPlace(BlockPlaceEvent event) {
  locations.add(event.getBlock().getLocation()); // set prevents duplicates
}