use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by Trichtern.
the class WorldManipulateListener method onBlockBreak.
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
if (event.isCancelled()) {
return;
}
Player player = event.getPlayer();
BuildWorld buildWorld = worldManager.getBuildWorld(player.getWorld().getName());
if (buildWorld == null) {
return;
}
if (!manageWorldInteraction(player, event, buildWorld.isBlockBreaking())) {
setStatus(buildWorld, player);
}
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by Trichtern.
the class WorldManipulateListener method onPlayerInteract.
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event) {
ItemStack itemStack = event.getItem();
if (itemStack != null && itemStack.getType() == plugin.getConfigValues().getWorldEditWand().parseMaterial()) {
return;
}
Player player = event.getPlayer();
BuildWorld buildWorld = worldManager.getBuildWorld(player.getWorld().getName());
if (buildWorld == null) {
return;
}
manageWorldInteraction(player, event, buildWorld.isBlockInteractions());
if (!buildWorld.isPhysics() && event.getClickedBlock() != null) {
if (event.getAction() == Action.PHYSICAL && event.getClickedBlock().getType() == XMaterial.FARMLAND.parseMaterial()) {
event.setCancelled(true);
}
}
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by Trichtern.
the class InventoryManager method teleport.
private void teleport(Player player, String worldName) {
WorldManager worldManager = plugin.getWorldManager();
BuildWorld buildWorld = worldManager.getBuildWorld(worldName);
if (buildWorld == null) {
return;
}
worldManager.teleport(player, buildWorld);
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by Trichtern.
the class PlayerCommandPreprocessListener method onPlayerCommandPreprocess.
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (event.isCancelled()) {
return;
}
String command = event.getMessage().split(" ")[0];
Player player = event.getPlayer();
if (command.equalsIgnoreCase("/clear")) {
ItemStack navigatorItem = inventoryManager.getItemStack(configValues.getNavigatorItem(), plugin.getString("navigator_item"));
if (!player.getInventory().contains(navigatorItem)) {
return;
}
if (settingsManager.getSettings(player).isKeepNavigator()) {
List<Integer> navigatorSlots = inventoryManager.getNavigatorSlots(player);
Bukkit.getScheduler().runTaskLater(plugin, () -> {
PlayerInventoryClearEvent playerInventoryClearEvent = new PlayerInventoryClearEvent(player, navigatorSlots);
Bukkit.getServer().getPluginManager().callEvent(playerInventoryClearEvent);
}, 2L);
}
return;
}
if (configValues.isBlockWorldEditNonBuilder()) {
if (!DISABLED_COMMANDS.contains(command)) {
return;
}
BuildWorld buildWorld = worldManager.getBuildWorld(player.getWorld().getName());
if (buildWorld == null) {
return;
}
if (disableArchivedWorlds(buildWorld, player, event)) {
return;
}
checkBuilders(buildWorld, player, event);
}
}
use of com.eintosti.buildsystem.object.world.BuildWorld in project BuildSystem by Trichtern.
the class PlayerTeleportListener method onPlayerTeleport.
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer();
if (event.getCause() != PlayerTeleportEvent.TeleportCause.UNKNOWN) {
playerManager.getPreviousLocation().put(player.getUniqueId(), event.getFrom());
}
Location to = event.getTo();
if (to == null) {
return;
}
World toWorld = to.getWorld();
if (toWorld == null) {
return;
}
String worldName = to.getWorld().getName();
BuildWorld buildWorld = worldManager.getBuildWorld(worldName);
if (buildWorld == null) {
return;
}
if (!Bukkit.getWorlds().get(0).equals(Bukkit.getWorld(worldName))) {
if (!player.hasPermission(buildWorld.getPermission()) && !buildWorld.getPermission().equalsIgnoreCase("-")) {
player.sendMessage(plugin.getString("worlds_tp_entry_forbidden"));
event.setCancelled(true);
}
}
}
Aggregations