本文整理汇总了Java中org.spongepowered.api.event.block.ChangeBlockEvent.Place方法的典型用法代码示例。如果您正苦于以下问题:Java ChangeBlockEvent.Place方法的具体用法?Java ChangeBlockEvent.Place怎么用?Java ChangeBlockEvent.Place使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.event.block.ChangeBlockEvent
的用法示例。
在下文中一共展示了ChangeBlockEvent.Place方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerPlacesBlock
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onPlayerPlacesBlock(ChangeBlockEvent.Place event, @First Player player)
{
if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
{
return;
}
if (player.hasPermission("nations.admin.bypass.perm.build"))
{
return;
}
event
.getTransactions()
.stream()
.forEach(trans -> trans.getOriginal().getLocation().ifPresent(loc -> {
if (!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) {}
}
}));
}
示例2: onChangeBlock
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onChangeBlock(ChangeBlockEvent.Place event) {
Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
if (!optPlayer.isPresent()) return;
Player player = optPlayer.get();
if (!this.players.contains(player.getUniqueId())) return;
event.setCancelled(true);
event.getTransactions().forEach(transaction -> {
player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Type: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getState().getId()));
player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Owner: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getCreator()));
player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Notifier: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getNotifier()));
});
}
示例3: onBlockPlace
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockPlace(ChangeBlockEvent.Place event, @Root Player player) {
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
for (Transaction<BlockSnapshot> transaction : transactions) {
BlockSnapshot snapshot = transaction.getFinal();
BlockState blockState = snapshot.getState();
String blockTypeId = blockState.getType().getId();
String blockStateId = blockState.getId();
PermHandler ph = PermHandler.getInstance();
if (!ph.checkPerm(player, "protectionperms.block.place." + blockTypeId,
"protectionperms.block.place." + blockStateId)) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to place " + blockState.getName() + '!'));
break;
}
}
}
示例4: onPlaceBlock
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onPlaceBlock(ChangeBlockEvent.Place event, @Root Player player)
{
if (!player.hasPermission("essentialcmds.blacklist.bypass"))
{
for (Transaction<BlockSnapshot> transaction : event.getTransactions())
{
if (Utils.getBlacklistItems().contains(transaction.getFinal().getState().getType().getId()))
{
if (Utils.areBlacklistMsgsEnabled())
player.sendMessage(Text.of(TextColors.RED, "The item ", TextColors.GRAY, transaction.getFinal().getState().getType().getId(), TextColors.RED, " has been confiscated as it is blacklisted."));
event.setCancelled(true);
}
}
}
}
示例5: onBlockPlace
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockPlace(ChangeBlockEvent.Place event, @Named(NamedCause.SOURCE) Player player) {
Optional<CursedMineInstance> optInst = manager.getApplicableZone(player);
if (!optInst.isPresent()) {
return;
}
for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
BlockType originalType = transaction.getFinal().getState().getType();
BlockType finalType = transaction.getFinal().getState().getType();
if (isRedstoneTransition(originalType, finalType)) {
continue;
}
event.setCancelled(true);
break;
}
}
示例6: blockplace
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void blockplace(final ChangeBlockEvent.Place event, @First Player player)
{
if (this.unlimitedPlayers.contains(player.getUniqueId()))
{
if (player.getGameModeData().type().get() == GameModes.CREATIVE)
{
return;
}
ItemStack item = player.getItemInHand(HandTypes.MAIN_HAND).orElse(null);
if (item != null)
{
item.setQuantity(item.getQuantity() + 1);
player.setItemInHand(HandTypes.MAIN_HAND, item);
}
}
}
示例7: onWaterLavaFlow
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onWaterLavaFlow(ChangeBlockEvent.Place event)
{
if (!this.module.getConfig().protectBlocksFromWaterLava)
{
return;
}
// do not allow change
event.getTransactions().stream()
.filter(trans -> trans.getFinal().getState().getType().getProperty(MatterProperty.class).get().getValue() == LIQUID)
.forEach(trans -> {
Location<World> location = trans.getOriginal().getLocation().get();
if (manager.getLock(location) != null)
{
trans.setCustom(trans.getOriginal()); // do not allow change
}
});
}
示例8: onBlockPlace
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order = POST)
public void onBlockPlace(ChangeBlockEvent.Place event, @First Player player)
{
EntityArchetype hidden = EntityArchetype.builder().type(SNOWBALL).set(Keys.INVISIBLE, true).build();
Optional<ItemStackSnapshot> inHand = event.getContext().get(EventContextKeys.USED_ITEM);
if (inHand.isPresent() &&
places(event, MOB_SPAWNER) &&
hasEnchantment(inHand.get(), LURE))
{
for (Transaction<BlockSnapshot> trans : event.getTransactions())
{
if (trans.getFinal().getState().getType().equals(MOB_SPAWNER))
{
BlockSnapshot snap = trans.getFinal();
snap.getLocation().get().offer(Keys.SPAWNER_ENTITIES, new WeightedTable<>());
snap.getLocation().get().offer(Keys.SPAWNER_NEXT_ENTITY_TO_SPAWN, new WeightedSerializableObject<>(hidden, 1));
i18n.send(player, POSITIVE, "Inactive Monster Spawner placed!");
return;
}
}
}
}
示例9: onBlockPlace
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void onBlockPlace(ChangeBlockEvent.Place e, @Root Player p) {
long time = new Date().getTime();
for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
UUID id = p.getUniqueId();
if (transaction.getOriginal().getState().getType() != BlockTypes.AIR) {
db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.DESTROY, id.toString(), time));
}
db.addToQueue(new BlockQueueEntry(transaction.getFinal(), ActionType.PLACE, id.toString(), time));
}
}
示例10: onBlockPlace
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void onBlockPlace(ChangeBlockEvent.Place e, @Root Agent a) {
if (a instanceof Player) return;
long time = new Date().getTime();
for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
String type = a.getType().getName();
if (transaction.getOriginal().getState().getType() != BlockTypes.AIR) {
db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.MOB_DESTROY, type, time));
}
db.addToQueue(new BlockQueueEntry(transaction.getFinal(), ActionType.MOB_PLACE, type, time));
}
}
示例11: onBlockPlace
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void onBlockPlace(ChangeBlockEvent.Place e, @Root Entity ent) {
if (ent instanceof Player || ent instanceof Agent) return;
long time = new Date().getTime();
for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
String name = ent.getType().getName();
if (transaction.getOriginal().getState().getType() != BlockTypes.AIR) {
db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.MOB_DESTROY, name, time));
}
db.addToQueue(new BlockQueueEntry(transaction.getFinal(), ActionType.MOB_PLACE, name, time));
}
}
示例12: ignore
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
/**
* Determine if we'll ignore messaging the player for this event/transaction combo.
*
* @param event Event
* @param transaction Block transaction
* @return
*/
public static boolean ignore(ChangeBlockEvent event, Transaction<BlockSnapshot> transaction) {
if (event instanceof ChangeBlockEvent.Place) {
return ignorePlaceCombination(transaction.getOriginal().getState().getType(), transaction.getFinal().getState().getType());
} else {
return ignoreBreakCombination(transaction.getOriginal().getState().getType(), transaction.getFinal().getState().getType());
}
}
示例13: onPlaceBlock
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onPlaceBlock(final ChangeBlockEvent.Place event) {
Optional<Player> player = event.getCause().first(Player.class);
// Allow if they have mod permission
if (player.isPresent() && player.get().hasPermission("safeguard.mod")) {
return;
}
for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
List<Zone> zones = SafeGuard.getZoneManager().getZones(transaction.getOriginal().getLocation().get());
// Allow change if no zone exists
if (zones.isEmpty()) {
continue;
}
for (Zone zone : zones) {
// Reject if zone doesn't permit
if (!zone.allows(player, flag)) {
transaction.setValid(false);
// Should we message the player?
if (player.isPresent() && !BlockUtil.ignore(event, transaction)) {
String block = transaction.getOriginal().getState().getType().getName();
player.get().sendMessage(Format.error(String.format("Zone does not allow you to place %s.",
block.replace("minecraft:", ""))));
}
break;
}
}
}
}
示例14: placeBlock
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void placeBlock(ChangeBlockEvent.Place e, @Root Player player) {
if (isOnPipe(player.getUniqueId())) {
Location loc = e.getTransactions().get(0).getFinal().getLocation().get();
getUserConnection(player.getUniqueId())
.get(EntityTracker.class)
.addBlockInteraction(new Position((long) loc.getX(), (long) loc.getY(), (long) loc.getZ()));
}
}
示例15: onBlockPlaced
import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockPlaced(ChangeBlockEvent.Place evt, @Root Player player) {
for (Transaction<BlockSnapshot> block : evt.getTransactions()) {
PlayerPlacesBlockScriptEvent event = (PlayerPlacesBlockScriptEvent) clone();
event.internal = evt;
event.block = block;
event.player = new PlayerTag(player);
event.material = new BlockTypeTag(block.getFinal().getState().getType());
event.old_material = new BlockTypeTag(block.getOriginal().getState().getType());
event.location = new LocationTag(block.getOriginal().getLocation().get());
event.cancelled = evt.isCancelled();
event.run();
evt.setCancelled(event.cancelled);
}
}