org.spongepowered.api.event.filter.cause.First Java Examples
The following examples show how to use
org.spongepowered.api.event.filter.cause.First.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BuildPermListener.java From Nations with MIT License | 6 votes |
@Listener(order=Order.FIRST, beforeModifications = true) public void onPlayerPlacesBlock(ChangeBlockEvent.Place event, @First Player player) { if (player.hasPermission("nations.admin.bypass.perm.build")) { return; } event .getTransactions() .stream() .forEach(trans -> trans.getOriginal().getLocation().ifPresent(loc -> { if (ConfigHandler.getNode("worlds").getNode(trans.getFinal().getLocation().get().getExtent().getName()).getNode("enabled").getBoolean() && !ConfigHandler.isWhitelisted("build", trans.getFinal().getState().getType().getId()) && !DataHandler.getPerm("build", player.getUniqueId(), loc)) { trans.setValid(false); try { player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD)); } catch (Exception e) {} } })); }
Example #2
Source File: VirtualChestPlugin.java From VirtualChest with GNU Lesser General Public License v3.0 | 6 votes |
@Listener(order = Order.EARLY) public void onInteractItemSecondary(InteractItemEvent.Secondary event, @First Player player) { String name = ""; for (String inventoryName : this.dispatcher.ids()) { if (player.hasPermission("virtualchest.open.self." + inventoryName)) { if (this.dispatcher.isInventoryMatchingSecondaryAction(inventoryName, event.getItemStack())) { event.setCancelled(true); name = inventoryName; break; } } } if (!name.isEmpty()) { this.logger.debug("Player {} tries to create the GUI ({}) by secondary action", player.getName(), name); this.dispatcher.open(name, player); } }
Example #3
Source File: PlayerEventHandler.java From GriefDefender with MIT License | 6 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onPlayerUseItem(UseItemStackEvent.Start event, @First Player player) { if (!GDFlags.ITEM_USE || !GriefDefenderPlugin.getInstance().claimsEnabledForWorld(player.getWorld().getUniqueId())) { return; } if (GriefDefenderPlugin.isTargetIdBlacklisted(Flags.ITEM_USE.getName(), event.getItemStackInUse().getType(), player.getWorld().getProperties())) { return; } GDTimings.PLAYER_USE_ITEM_EVENT.startTimingIfSync(); Location<World> location = player.getLocation(); GDPlayerData playerData = this.dataStore.getOrCreatePlayerData(location.getExtent(), player.getUniqueId()); GDClaim claim = this.dataStore.getClaimAtPlayer(playerData, location); final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.ITEM_USE, player, event.getItemStackInUse().getType(), player, TrustTypes.ACCESSOR, true); if (result == Tristate.FALSE) { final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_ITEM_USE, ImmutableMap.of( "item", event.getItemStackInUse().getType().getId())); GriefDefenderPlugin.sendClaimDenyMessage(claim, player, message); event.setCancelled(true); } GDTimings.PLAYER_USE_ITEM_EVENT.stopTimingIfSync(); }
Example #4
Source File: VirtualChestPlugin.java From VirtualChest with GNU Lesser General Public License v3.0 | 6 votes |
@Listener(order = Order.EARLY) public void onInteractItemPrimary(InteractItemEvent.Primary event, @First Player player) { String name = ""; for (String inventoryName : this.dispatcher.ids()) { if (player.hasPermission("virtualchest.open.self." + inventoryName)) { if (this.dispatcher.isInventoryMatchingPrimaryAction(inventoryName, event.getItemStack())) { event.setCancelled(true); name = inventoryName; break; } } } if (!name.isEmpty()) { this.logger.debug("Player {} tries to create the GUI ({}) by primary action", player.getName(), name); this.dispatcher.open(name, player); } }
Example #5
Source File: UCListener.java From UltimateChat with GNU General Public License v3.0 | 6 votes |
@Listener(order = Order.POST) public void onCommand(SendCommandEvent e, @First CommandSource p) { // Deny command if muted if (p instanceof Player && UChat.get().mutes.contains(p.getName()) && UChat.get().getConfig().root().general.muted_deny_cmds.contains(e.getCommand())) { UChat.get().getLang().sendMessage(p, "player.muted.denycmd"); e.setCancelled(true); return; } if (UChat.get().getUCJDA() != null) { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); Task.builder().async().execute(() -> UChat.get().getUCJDA().sendCommandsToDiscord(UChat.get().getLang().get("discord.command") .replace("{player}", p.getName()) .replace("{cmd}", "/" + e.getCommand() + " " + e.getArguments()) .replace("{time-now}", sdf.format(cal.getTime())))); } }
Example #6
Source File: BuildPermListener.java From Nations with MIT License | 6 votes |
@Listener(order=Order.FIRST, beforeModifications = true) public void onEntitySpawn(SpawnEntityEvent event, @First Player player) { if (player.hasPermission("nations.admin.bypass.perm.build")) { return; } if (event.getCause().contains(SpawnTypes.PLACEMENT)) { try { if (!ConfigHandler.getNode("worlds").getNode(event.getEntities().get(0).getWorld().getName()).getNode("enabled").getBoolean()) return; if (!ConfigHandler.isWhitelisted("spawn", event.getEntities().get(0).getType().getId()) && !DataHandler.getPerm("build", player.getUniqueId(), event.getEntities().get(0).getLocation())) event.setCancelled(true); } catch (IndexOutOfBoundsException e) {} } }
Example #7
Source File: BuildPermListener.java From Nations with MIT License | 6 votes |
@Listener(order=Order.FIRST, beforeModifications = true) public void onPlayerModifyBlock(ChangeBlockEvent.Modify event, @First Player player) { if (player.hasPermission("nations.admin.bypass.perm.build")) { return; } event .getTransactions() .stream() .forEach(trans -> trans.getOriginal().getLocation().ifPresent(loc -> { if (ConfigHandler.getNode("worlds").getNode(trans.getFinal().getLocation().get().getExtent().getName()).getNode("enabled").getBoolean() && !ConfigHandler.isWhitelisted("build", trans.getFinal().getState().getType().getId()) && !DataHandler.getPerm("build", player.getUniqueId(), loc)) { trans.setValid(false); try { player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD)); } catch (Exception e) {} } })); }
Example #8
Source File: BuildPermListener.java From Nations with MIT License | 6 votes |
@Listener(order=Order.FIRST, beforeModifications = true) public void onPlayerChangeBlock(ChangeBlockEvent.Pre event, @First Player player) { if (player.hasPermission("nations.admin.bypass.perm.build")) { return; } if (Utils.isFakePlayer(event)) { return; } for (Location<World> loc : event.getLocations()) { if (ConfigHandler.getNode("worlds").getNode(loc.getExtent().getName()).getNode("enabled").getBoolean() && !ConfigHandler.isWhitelisted("break", loc.getBlock().getId()) && !DataHandler.getPerm("build", player.getUniqueId(), loc)) { event.setCancelled(true); try { player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD)); } catch (Exception e) {} return; } } }
Example #9
Source File: BuildPermListener.java From Nations with MIT License | 6 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onSignChanged(ChangeSignEvent event, @First User player) { if (!ConfigHandler.getNode("worlds").getNode(event.getTargetTile().getLocation().getExtent().getName()).getNode("enabled").getBoolean()) { return; } if (player.hasPermission("nations.admin.bypass.perm.build")) { return; } if (!DataHandler.getPerm("build", player.getUniqueId(), event.getTargetTile().getLocation())) { event.setCancelled(true); } }
Example #10
Source File: BlockListener.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onInteractBlock(InteractBlockEvent event, @First Player p) { BlockSnapshot b = event.getTargetBlock(); Location<World> l; RedProtect.get().logger.debug(LogLevel.PLAYER, "BlockListener - Is InteractBlockEvent event"); if (!b.getState().getType().equals(BlockTypes.AIR)) { l = b.getLocation().get(); RedProtect.get().logger.debug(LogLevel.PLAYER, "BlockListener - Is InteractBlockEvent event. The block is " + b.getState().getType().getName()); } else { l = p.getLocation(); } Region r = RedProtect.get().rm.getTopRegion(l, this.getClass().getName()); if (r != null) { ItemType itemInHand = RedProtect.get().getVersionHelper().getItemInHand(p); if (itemInHand.equals(ItemTypes.ARMOR_STAND) && !r.canBuild(p)) { RedProtect.get().lang.sendMessage(p, "blocklistener.region.cantbuild"); event.setCancelled(true); } } }
Example #11
Source File: BlockListener.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onFlow(ChangeBlockEvent.Pre e, @First LocatableBlock locatable) { RedProtect.get().logger.debug(LogLevel.BLOCKS, "Is BlockListener - onFlow event"); BlockState sourceState = locatable.getBlockState(); //liquid check MatterProperty mat = sourceState.getProperty(MatterProperty.class).orElse(null); if (mat != null && mat.getValue() == MatterProperty.Matter.LIQUID) { e.getLocations().forEach(loc -> { Region r = RedProtect.get().rm.getTopRegion(loc, this.getClass().getName()); if (r != null && !r.canFlow()) { e.setCancelled(true); } }); } }
Example #12
Source File: InteractPermListener.java From Nations with MIT License | 6 votes |
@Listener(order=Order.FIRST, beforeModifications = true) public void onInteract(InteractBlockEvent event, @First Player player) { if (!ConfigHandler.getNode("worlds").getNode(player.getWorld().getName()).getNode("enabled").getBoolean()) { return; } if (player.hasPermission("nations.admin.bypass.perm.interact")) { return; } Optional<ItemStack> optItem = player.getItemInHand(HandTypes.MAIN_HAND); if (optItem.isPresent() && (ConfigHandler.isWhitelisted("use", optItem.get().getItem().getId()) || optItem.get().getItem().equals(ItemTypes.GOLDEN_AXE) && ConfigHandler.getNode("others", "enableGoldenAxe").getBoolean(true))) return; event.getTargetBlock().getLocation().ifPresent(loc -> { if (!DataHandler.getPerm("interact", player.getUniqueId(), loc)) { event.setCancelled(true); if (loc.getBlockType() != BlockTypes.STANDING_SIGN && loc.getBlockType() != BlockTypes.WALL_SIGN) player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_INTERACT)); } }); }
Example #13
Source File: PlayerListener.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onEntityDamageByEntityEvent(InteractEntityEvent.Primary e, @First Player p) { Entity e1 = e.getTargetEntity(); RedProtect.get().logger.debug(LogLevel.PLAYER, "RPLayerListener: Is EntityDamageByEntityEvent event. Victim: " + e.getTargetEntity().getType().getName()); Location<World> l = e1.getLocation(); Region r = RedProtect.get().rm.getTopRegion(l, this.getClass().getName()); if (r == null || p == null) { return; } if (e1 instanceof Player && r.flagExists("pvp") && !r.canPVP(p, (Player) e1)) { RedProtect.get().lang.sendMessage(p, "entitylistener.region.cantpvp"); e.setCancelled(true); } }
Example #14
Source File: PlayerEventHandler.java From GriefPrevention with MIT License | 6 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onPlayerUseItem(UseItemStackEvent.Start event, @First Player player) { if (!GPFlags.ITEM_USE || !GriefPreventionPlugin.instance.claimsEnabledForWorld(player.getWorld().getProperties())) { return; } if (GriefPreventionPlugin.isTargetIdBlacklisted(ClaimFlag.ITEM_USE.toString(), event.getItemStackInUse().getType(), player.getWorld().getProperties())) { return; } GPTimings.PLAYER_USE_ITEM_EVENT.startTimingIfSync(); Location<World> location = player.getLocation(); GPPlayerData playerData = this.dataStore.getOrCreatePlayerData(location.getExtent(), player.getUniqueId()); GPClaim claim = this.dataStore.getClaimAtPlayer(playerData, location); final Tristate result = GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.ITEM_USE, player, event.getItemStackInUse().getType(), player, TrustType.ACCESSOR, true); if (result == Tristate.FALSE) { final Text message = GriefPreventionPlugin.instance.messageData.permissionItemUse .apply(ImmutableMap.of( "item", event.getItemStackInUse().getType().getId())).build(); GriefPreventionPlugin.sendClaimDenyMessage(claim, player, message); event.setCancelled(true); } GPTimings.PLAYER_USE_ITEM_EVENT.stopTimingIfSync(); }
Example #15
Source File: GlobalListener.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onFireSpread(ChangeBlockEvent.Break e, @First LocatableBlock locatable) { RedProtect.get().logger.debug(LogLevel.BLOCKS, "GlobalListener - Is onBlockBreakGeneric event"); BlockState sourceState = locatable.getBlockState(); if (sourceState.getType() == BlockTypes.FIRE) { BlockSnapshot b = e.getTransactions().get(0).getOriginal(); boolean fireDamage = RedProtect.get().config.globalFlagsRoot().worlds.get(locatable.getLocation().getExtent().getName()).fire_block_damage; if (!fireDamage && b.getState().getType() != BlockTypes.FIRE) { Region r = RedProtect.get().rm.getTopRegion(b.getLocation().get(), this.getClass().getName()); if (r == null) { RedProtect.get().logger.debug(LogLevel.BLOCKS, "Tryed to break from FIRE!"); e.setCancelled(true); } } } }
Example #16
Source File: GlobalListener.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onFireSpread(ChangeBlockEvent.Place e, @First LocatableBlock locatable) { RedProtect.get().logger.debug(LogLevel.BLOCKS, "GlobalListener - Is onFireSpread event!"); BlockState sourceState = locatable.getBlockState(); if (e.getTransactions().get(0).getFinal().getState().getType().equals(BlockTypes.FIRE) && (sourceState.getType() == BlockTypes.FIRE || sourceState.getType() == BlockTypes.LAVA || sourceState.getType() == BlockTypes.FLOWING_LAVA)) { boolean fireDamage = RedProtect.get().config.globalFlagsRoot().worlds.get(locatable.getLocation().getExtent().getName()).fire_spread; if (!fireDamage) { Region r = RedProtect.get().rm.getTopRegion(e.getTransactions().get(0).getOriginal().getLocation().get(), this.getClass().getName()); if (r == null) { RedProtect.get().logger.debug(LogLevel.BLOCKS, "Tryed to PLACE FIRE!"); e.setCancelled(true); } } } }
Example #17
Source File: EntityListener.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onInteractEvent(InteractEntityEvent.Secondary e, @First Player p) { Entity et = e.getTargetEntity(); Location<World> l = et.getLocation(); Region r = RedProtect.get().rm.getTopRegion(l, this.getClass().getName()); RedProtect.get().logger.debug(LogLevel.ENTITY, "EntityListener - InteractEntityEvent.Secondary entity " + et.getType().getName()); if (r != null && !r.canInteractPassives(p) && (et instanceof Animal || et instanceof Villager || et instanceof Golem || et instanceof Ambient)) { if (RedProtect.get().getVersionHelper().checkHorseOwner(et, p)) { return; } e.setCancelled(true); RedProtect.get().lang.sendMessage(p, "entitylistener.region.cantinteract"); } }
Example #18
Source File: GlobalListener.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onFlow(ChangeBlockEvent.Pre e, @First LocatableBlock locatable) { RedProtect.get().logger.debug(LogLevel.BLOCKS, "Is BlockListener - onFlow event"); BlockState sourceState = locatable.getBlockState(); //liquid check MatterProperty mat = sourceState.getProperty(MatterProperty.class).orElse(null); if (mat != null && mat.getValue() == MatterProperty.Matter.LIQUID) { e.getLocations().forEach(loc -> { Region r = RedProtect.get().rm.getTopRegion(loc, this.getClass().getName()); if (r == null) { boolean flow = RedProtect.get().config.globalFlagsRoot().worlds.get(locatable.getLocation().getExtent().getName()).allow_changes_of.liquid_flow; boolean allowWater = RedProtect.get().config.globalFlagsRoot().worlds.get(locatable.getLocation().getExtent().getName()).allow_changes_of.water_flow; boolean allowLava = RedProtect.get().config.globalFlagsRoot().worlds.get(locatable.getLocation().getExtent().getName()).allow_changes_of.lava_flow; if (!flow) e.setCancelled(true); if (!allowWater && (loc.getBlockType() == BlockTypes.WATER || loc.getBlockType() == BlockTypes.FLOWING_WATER)) e.setCancelled(true); if (!allowLava && (loc.getBlockType() == BlockTypes.LAVA || loc.getBlockType() == BlockTypes.FLOWING_LAVA)) e.setCancelled(true); } }); } }
Example #19
Source File: ConnectionListener.java From FlexibleLogin with MIT License | 5 votes |
@Listener public void onPlayerQuit(Disconnect playerQuitEvent, @First Player player) { Optional<Account> optAccount = plugin.getDatabase().remove(player); optAccount.ifPresent(account -> { //account is loaded -> mark the player as logout as it could remain in the cache account.setLoggedIn(false); if (settings.getGeneral().isUpdateLoginStatus()) { Task.builder() .async() .execute(() -> plugin.getDatabase().save(account)) .submit(plugin); } }); }
Example #20
Source File: EntityEventHandler.java From GriefDefender with MIT License | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onEntityDamage(DamageEntityEvent event, @First DamageSource damageSource) { GDTimings.ENTITY_DAMAGE_EVENT.startTimingIfSync(); if (protectEntity(event, event.getTargetEntity(), event.getCause(), damageSource)) { event.setCancelled(true); } GDTimings.ENTITY_DAMAGE_EVENT.stopTimingIfSync(); }
Example #21
Source File: RPBlockListener8.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onPlayerDie(DestructEntityEvent.Death e, @First Player p) { Region r = RedProtect.get().rm.getTopRegion(p.getLocation(), this.getClass().getName()); if (r != null && !r.keepInventory()) { e.setKeepInventory(true); } }
Example #22
Source File: PlayerListener.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onPlayerInteract(InteractEntityEvent e, @First Player p) { Entity ent = e.getTargetEntity(); RedProtect.get().logger.debug(LogLevel.PLAYER, "PlayerListener - Is InteractEntityEvent event: " + ent.getType().getName()); Location<World> l = ent.getLocation(); Region r = RedProtect.get().rm.getTopRegion(l, this.getClass().getName()); if (r == null) { return; } if (RedProtect.get().tpWait.contains(p.getName())) { RedProtect.get().tpWait.remove(p.getName()); RedProtect.get().lang.sendMessage(p, "cmdmanager.region.tpcancelled"); } if (ent instanceof Hanging || ent.getType().equals(EntityTypes.ARMOR_STAND) || ent.getType().equals(EntityTypes.ENDER_CRYSTAL)) { if (!r.canBuild(p)) { RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantinteract"); e.setCancelled(true); } } else if (ent instanceof Minecart || ent instanceof Boat) { if (!r.canMinecart(p)) { RedProtect.get().lang.sendMessage(p, "blocklistener.region.cantenter"); e.setCancelled(true); } } else if (!r.allowMod(p) && !RedProtect.get().getUtil().isBukkitEntity(ent) && (!(ent instanceof Player))) { RedProtect.get().logger.debug(LogLevel.PLAYER, "PlayerInteractEntityEvent - Block is " + ent.getType().getName()); RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantinteract"); e.setCancelled(true); } }
Example #23
Source File: PlayerListener.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Listener(order = Order.FIRST) public void onInteractLeft(InteractBlockEvent.Primary event, @First Player p) { BlockSnapshot b = event.getTargetBlock(); Location<World> l; RedProtect.get().logger.debug(LogLevel.PLAYER, "PlayerListener - Is InteractBlockEvent.Primary event"); if (!b.getState().getType().equals(BlockTypes.AIR)) { l = b.getLocation().get(); RedProtect.get().logger.debug(LogLevel.PLAYER, "PlayerListener - Is InteractBlockEvent.Primary event. The block is " + b.getState().getType().getName()); } else { l = p.getLocation(); } ItemType itemInHand = RedProtect.get().getVersionHelper().getItemInHand(p); String claimmode = RedProtect.get().config.getWorldClaimType(p.getWorld().getName()); if (event instanceof InteractBlockEvent.Primary.MainHand && itemInHand.getId().equalsIgnoreCase(RedProtect.get().config.configRoot().wands.adminWandID) && ((claimmode.equalsIgnoreCase("WAND") || claimmode.equalsIgnoreCase("BOTH")) || RedProtect.get().ph.hasPerm(p, "redprotect.admin.claim"))) { if (!RedProtect.get().getUtil().canBuildNear(p, l)) { event.setCancelled(true); return; } RedProtect.get().firstLocationSelections.put(p, l); p.sendMessage(RedProtect.get().getUtil().toText(RedProtect.get().lang.get("playerlistener.wand1") + RedProtect.get().lang.get("general.color") + " (&e" + l.getBlockX() + RedProtect.get().lang.get("general.color") + ", &e" + l.getBlockY() + RedProtect.get().lang.get("general.color") + ", &e" + l.getBlockZ() + RedProtect.get().lang.get("general.color") + ").")); event.setCancelled(true); //show preview border previewSelection(p); } }
Example #24
Source File: PlayerListener.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onConsume(UseItemStackEvent.Start e, @First Player p) { ItemStack stack = e.getItemStackInUse().createStack(); RedProtect.get().logger.debug(LogLevel.PLAYER, "Is UseItemStackEvent.Start event. Item: " + RedProtect.get().getVersionHelper().getItemType(stack).getName()); //deny potion List<String> Pots = RedProtect.get().config.globalFlagsRoot().worlds.get(p.getWorld().getName()).deny_potions; if (stack.get(Keys.POTION_EFFECTS).isPresent() && Pots.size() > 0) { List<PotionEffect> pot = stack.get(Keys.POTION_EFFECTS).get(); for (PotionEffect pots : pot) { if (Pots.contains(pots.getType().getName().toUpperCase()) && !p.hasPermission("redprotect.bypass")) { e.setCancelled(true); RedProtect.get().lang.sendMessage(p, "playerlistener.denypotion"); } } } Region r = RedProtect.get().rm.getTopRegion(p.getLocation(), this.getClass().getName()); if (r != null && RedProtect.get().getVersionHelper().getItemType(stack).equals(ItemTypes.POTION) && !r.usePotions(p)) { RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantuse"); e.setCancelled(true); } if (r != null && RedProtect.get().getVersionHelper().getItemType(stack).getName().equals("minecraft:chorus_fruit") && !r.canTeleport(p)) { RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantuse"); e.setCancelled(true); } }
Example #25
Source File: PlayerListener.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onPressPlateChange(CollideBlockEvent e, @First Player p) { if (e.getTargetBlock().getName().contains("pressure_plate")) { Location<World> loc = e.getTargetLocation(); Region r = RedProtect.get().rm.getTopRegion(loc, this.getClass().getName()); if (r != null && !r.allowPressPlate(p)) { e.setCancelled(true); RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantpressplate"); } } }
Example #26
Source File: ConnectionListener.java From FlexibleLogin with MIT License | 5 votes |
@Listener(order = Order.LATE) public void checkCaseSensitive(Auth authEvent, @First GameProfile profile) { String playerName = profile.getName().get(); if (settings.getGeneral().isCaseSensitiveNameCheck()) { plugin.getDatabase().exists(playerName) .filter(databaseName -> !playerName.equals(databaseName)) .ifPresent(databaseName -> { authEvent.setMessage(settings.getText().getInvalidCase(databaseName)); authEvent.setCancelled(true); }); } }
Example #27
Source File: ConnectionListener.java From FlexibleLogin with MIT License | 5 votes |
@Listener public void loadAccountOnJoin(Join playerJoinEvent, @First Player player) { Task.builder() .async() .execute(() -> onAccountLoaded(player)) .submit(plugin); }
Example #28
Source File: PreventListener.java From FlexibleLogin with MIT License | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onPlayerMove(MoveEntityEvent playerMoveEvent, @First Player player) { if (playerMoveEvent instanceof MoveEntityEvent.Teleport) { return; } Vector3i oldLocation = playerMoveEvent.getFromTransform().getPosition().toInt(); Vector3i newLocation = playerMoveEvent.getToTransform().getPosition().toInt(); if (oldLocation.getX() != newLocation.getX() || oldLocation.getZ() != newLocation.getZ()) { checkLoginStatus(playerMoveEvent, player); } }
Example #29
Source File: PreventListener.java From FlexibleLogin with MIT License | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onCommand(SendCommandEvent commandEvent, @First Player player) { String command = commandEvent.getCommand(); Optional<? extends CommandMapping> commandOpt = commandManager.get(command); if (commandOpt.isPresent()) { CommandMapping mapping = commandOpt.get(); command = mapping.getPrimaryAlias(); //do not blacklist our own commands if (commandManager.getOwner(mapping) .map(pc -> pc.getId().equals(PomData.ARTIFACT_ID)) .orElse(false)) { return; } } commandEvent.setResult(CommandResult.empty()); if (settings.getGeneral().isCommandOnlyProtection()) { List<String> protectedCommands = settings.getGeneral().getProtectedCommands(); if (protectedCommands.contains(command) && !plugin.getDatabase().isLoggedIn(player)) { player.sendMessage(settings.getText().getProtectedCommand()); commandEvent.setCancelled(true); } } else { checkLoginStatus(commandEvent, player); } }
Example #30
Source File: BlockListener.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onBlockBreak(ChangeBlockEvent.Break e, @First Player p) { RedProtect.get().logger.debug(LogLevel.BLOCKS, "BlockListener - Is ChangeBlockEvent.Break event!"); BlockSnapshot b = e.getTransactions().get(0).getOriginal(); Location<World> bloc = b.getLocation().get(); boolean antih = RedProtect.get().config.configRoot().region_settings.anti_hopper; Region r = RedProtect.get().rm.getTopRegion(bloc, this.getClass().getName()); if (!RedProtect.get().ph.hasPerm(p, "redprotect.bypass")) { BlockSnapshot ib = bloc.getBlockRelative(Direction.UP).createSnapshot(); if ((antih && !cont.canBreak(p, ib)) || !cont.canBreak(p, b)) { RedProtect.get().lang.sendMessage(p, "blocklistener.container.breakinside"); e.setCancelled(true); return; } } if (r == null && canBreakList(p.getWorld(), b.getState().getType().getName())) { return; } if (r != null && b.getState().getType().equals(BlockTypes.MOB_SPAWNER) && r.allowSpawner(p)) { return; } if (r != null && r.canBuild(p) && b.getState().getType().getName().equalsIgnoreCase("sign")) { Sign s = (Sign) b.getLocation().get().getTileEntity().get(); if (s.lines().get(0).toPlain().equalsIgnoreCase("[flag]")) { RedProtect.get().config.removeSign(r.getID(), b.getLocation().get()); return; } } if (r != null && !r.canBuild(p) && !r.canTree(b) && !r.canMining(b) && !r.canCrops(b) && !r.canBreak(b)) { RedProtect.get().lang.sendMessage(p, "blocklistener.region.cantbuild"); e.setCancelled(true); } }