#TitleAPI help
1 messages · Page 1 of 1 (latest)
hello
yo
which error?
Could not pass event PlayerJoinEvent to gabby128bit v2.0
it cannot find the api thing
how i resolve it?
is titleapi a plugin
not an api?
put that in your plugins folder
it's this it's a api
oh wait
okay
OHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
IM FUKING STUPID
if something has an onEnable method , does it makes that a plugin? @sinful rain
i think youre not loading it as a plugin
extending JavaPlugin
technically
i test on 1.17
ye then this is a plugin
you need to put the 'api' into your plugins folder
Ok
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
ok
IT WORK'S YEAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
i have other problem
what?
how do i make a plugin where no player can break blocks in the map?
listen for the block break event and cancel it
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
so open the inventory for the player i guess?
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
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
event.setCancelled(true);
}
}
it's correct?
ye it will not allow anyone to break a block
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);
}
are you sure you registered the event?
are there other plugins which override the cancelling of the event?
i put it in to main
then normally it should work
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?
??????????
hello
The most simple solution would be giving the players wool or something to build with and only allow wool to je broken
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
nooooooooooooooooooooooooooooo
i want to make players block broken = true
and i want to make players block broke with hand or tools
You want to make players can break blocks?
you're not properly explaining what you're trying to do
i want to make players can break block but not the map block
map block = blocks of the server
we explained you how to do it the best way
BRUH
....................................................................................................................................................................................................................
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
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
}