• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ChangeMode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ch.njol.skript.classes.Changer.ChangeMode的典型用法代码示例。如果您正苦于以下问题:Java ChangeMode类的具体用法?Java ChangeMode怎么用?Java ChangeMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ChangeMode类属于ch.njol.skript.classes.Changer包,在下文中一共展示了ChangeMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: change

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
	Number strength = (Number)delta[0];
	if (block != null) {
		try {
			Number strengthNow = getHardness(block.getSingle(e));
			Method method = ReflectionUtil.getNMSClass("Block").getDeclaredMethod("c", Float.TYPE);
			method.setAccessible(true);
			Object nmsBlock = ReflectionUtil.getNMSBlock(block.getSingle(e));
			if (mode == ChangeMode.SET) {
				method.invoke(nmsBlock, strength.floatValue());
			} else if (mode == ChangeMode.ADD) {
				method.invoke(nmsBlock, strength.floatValue() + strengthNow.floatValue());
			} else if (mode == ChangeMode.REMOVE) {
				method.invoke(nmsBlock, strength.floatValue() - strengthNow.floatValue());
			}
		} catch (SecurityException | NoSuchMethodException | IllegalArgumentException | IllegalAccessException | InvocationTargetException | ClassNotFoundException e1) {
			e1.printStackTrace();
		}
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:22,代码来源:ExprBlockHardness.java


示例2: acceptChange

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	if (mode == ChangeMode.REMOVE_ALL)
		return null;
	if (ScriptLoader.isCurrentEvent(PlayerRespawnEvent.class) && !ScriptLoader.hasDelayBefore.isTrue()) {
		Skript.error("Cannot change a player's level in a respawn event. Add a delay of 1 tick or change the 'new level' in a death event.");
		return null;
	}
	if (ScriptLoader.isCurrentEvent(PlayerDeathEvent.class) && getTime() == 0 && getExpr().isDefault() && !ScriptLoader.hasDelayBefore.isTrue()) {
		Skript.warning("Changing the player's level in a death event will change the player's level before he dies. " +
				"Use either 'past level of player' or 'new level of player' to clearly state whether to change the level before or after he dies.");
	}
	if (getTime() == -1 && !ScriptLoader.isCurrentEvent(PlayerDeathEvent.class))
		return null;
	return new Class[] {Number.class};
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:18,代码来源:ExprLevel.java


示例3: acceptChange

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	if (mode == ChangeMode.DELETE && (type.acceptChange & ~PLAYER) != 0 || mode == ChangeMode.RESET)
		return new Class[0];
	if (mode != ChangeMode.SET)
		return null;
	if ((type.acceptChange & PLAYER) != 0 && Player.class.isAssignableFrom(getExpr().getReturnType())) {
		changeType = PLAYER;
	} else if ((type.acceptChange & ITEMSTACK) != 0 && (getExpr().isSingle() && ChangerUtils.acceptsChange(getExpr(), ChangeMode.SET, ItemStack.class, ItemType.class) || Slot.class.isAssignableFrom(getExpr().getReturnType()))) {
		changeType = ITEMSTACK;
	} else if ((type.acceptChange & ENTITY) != 0 && LivingEntity.class.isAssignableFrom(getExpr().getReturnType())) {
		if (type == NameType.NAME && Player.class.isAssignableFrom(getExpr().getReturnType())) {
			Skript.error("Cannot change the Minecraft name of a player. Change the 'display name of <player>' or 'tablist name of <player>' instead.");
			return null;
		}
		changeType = ENTITY;
	}
	return changeType == 0 ? null : CollectionUtils.array(String.class);
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:22,代码来源:ExprName.java


示例4: change

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
	if (entity.getSingle(e) == null) {
		return;
	}
	Number num = (Number)delta[0];
	Number numNow = ((Slime)entity.getSingle(e)).getSize();
	if (entity.getSingle(e).toString().equals("CraftSlime") || entity.getSingle(e).toString().equals("CraftMagmaCube")) {
		if (mode == ChangeMode.SET) {
			((Slime)entity.getSingle(e)).setSize(num.intValue());
		} else if (mode == ChangeMode.ADD) {
			((Slime)entity.getSingle(e)).setSize(numNow.intValue() + num.intValue());
		} else if (mode == ChangeMode.REMOVE) {
			((Slime)entity.getSingle(e)).setSize(numNow.intValue() - num.intValue());
		}
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:18,代码来源:ExprSlimeSize.java


示例5: change

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
	if (mode == ChangeMode.SET || mode == ChangeMode.DELETE) {
		final LivingEntity target = delta == null ? null : (LivingEntity) delta[0];
		for (final LivingEntity entity : getExpr().getArray(e)) {
			if (getTime() >= 0 && e instanceof EntityTargetEvent && entity.equals(((EntityTargetEvent) e).getEntity()) && !Delay.isDelayed(e)) {
				((EntityTargetEvent) e).setTarget(target);
			} else {
				if (entity instanceof Creature)
					((Creature) entity).setTarget(target);
			}
		}
	} else {
		super.change(e, delta, mode);
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:17,代码来源:ExprTarget.java


示例6: change

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
	if (mode == ChangeMode.SET) {
		if (block != null) {
			if (block.getSingle(e) instanceof Jukebox) {
				String type = (String)delta[0];
				try {
					Material material = Material.valueOf(type.replace("\"", "").trim().replace(" ", "_").toUpperCase());
					((Jukebox)block.getSingle(e)).setPlaying(material);
				} catch (IllegalArgumentException error) {
					Bukkit.getConsoleSender().sendMessage(Skellett.cc(Skellett.prefix + "&cUnknown material type " + type));
					return;
				}
			}
		}
	} else if (mode == ChangeMode.RESET) {
		if (((Jukebox)block.getSingle(e)).isPlaying()) {
			((Jukebox)block.getSingle(e)).eject();
		}
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:22,代码来源:ExprJukeboxMusic.java


示例7: acceptChange

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public Class<?>[] acceptChange(final ChangeMode mode) {
    if (mode == ChangeMode.SET || mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
        return CollectionUtils.array(String.class);
    }
    return null;
}
 
开发者ID:Pikachu920,项目名称:Ersatz,代码行数:8,代码来源:ExprResult.java


示例8: change

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, ChangeMode mode) {
    switch (mode) {
        case SET:
            ((PlaceholderAPIEvent) e).setResult((String) delta[0]);
            break;
        case RESET:
        case DELETE:
            ((PlaceholderAPIEvent) e).setResult(null);
            break;
    }
}
 
开发者ID:Pikachu920,项目名称:Ersatz,代码行数:13,代码来源:ExprResult.java


示例9: change

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
	if (mode == ChangeMode.SET) {
		ItemType item = (ItemType)delta[0];
		ItemStack m = item.getRandom();
		((InventoryClickEvent)e).setCurrentItem(m);
	}
}
 
开发者ID:WheezyGold7931,项目名称:skLib,代码行数:9,代码来源:ExprClickedItem.java


示例10: acceptChange

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Class<?>[] acceptChange(final Changer.ChangeMode mode) {
	if (mode == ChangeMode.SET) {
		return CollectionUtils.array(ItemType.class);
	}
	return null;
}
 
开发者ID:WheezyGold7931,项目名称:skLib,代码行数:9,代码来源:ExprClickedItem.java


示例11: acceptChange

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public Class<?>[] acceptChange(final Changer.ChangeMode mode) {
	if (mode == ChangeMode.SET || mode == ChangeMode.RESET || mode == ChangeMode.ADD || mode == ChangeMode.REMOVE) {
		return CollectionUtils.array(Number.class);
	}
	return null;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:8,代码来源:ExprBrewingFuelPower.java


示例12: change

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
	if (bar == null) {
		return;
	}
	BarColor colour = (BarColor)delta[0];
	if (mode == ChangeMode.SET) {
		bar.getSingle(e).setColor(colour);
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:11,代码来源:ExprBarColour.java


示例13: change

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
	Number itemAfter = (Number)delta[0];
	Number itemBefore = item.getSingle(e);
	ItemRemapperControl mapper = ProtocolSupportAPI.getItemRemapper(version.getSingle(e));
	if (mode == ChangeMode.SET) {
		mapper.setRemap(itemBefore.intValue(), itemAfter.intValue());
	} else if (mode == ChangeMode.RESET) {
		mapper.setRemap(itemAfter.intValue(), itemAfter.intValue());
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:12,代码来源:ExprItemRemapperID.java


示例14: acceptChange

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public Class<?>[] acceptChange(final Changer.ChangeMode mode) {
	if (mode == ChangeMode.SET || mode == ChangeMode.RESET || mode == ChangeMode.REMOVE) {
		return CollectionUtils.array(Object.class);
	}
	return null;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:8,代码来源:ExprNetworkVariable.java


示例15: acceptChange

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public Class<?>[] acceptChange(final Changer.ChangeMode mode) {
	if (mode == ChangeMode.SET) {
		return CollectionUtils.array(Boolean.class);
	}
	return null;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:8,代码来源:ExprAgeLock.java


示例16: acceptChange

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public Class<?>[] acceptChange(final Changer.ChangeMode mode) {
	if (mode == ChangeMode.SET) {
		return CollectionUtils.array(String.class);
	}
	return null;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:8,代码来源:ExprClientWeather.java


示例17: acceptChange

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	if (mode == ChangeMode.REMOVE_ALL)
		return null;
	return new Class[] {Number.class};
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:8,代码来源:ExprLevelProgress.java


示例18: change

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
	assert mode != ChangeMode.REMOVE_ALL;
	
	final float d = delta == null ? 0 : ((Number) delta[0]).floatValue();
	for (final Player p : getExpr().getArray(e)) {
		final float c;
		switch (mode) {
			case SET:
				c = d;
				break;
			case ADD:
				c = p.getExp() + d;
				break;
			case REMOVE:
				c = p.getExp() - d;
				break;
			case DELETE:
			case RESET:
				c = 0;
				break;
			case REMOVE_ALL:
			default:
				assert false;
				return;
		}
		p.setLevel(Math.max(0, p.getLevel() + (int) Math.floor(c)));
		p.setExp(Math2.mod(c, 1));
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:31,代码来源:ExprLevelProgress.java


示例19: acceptChange

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public Class<?>[] acceptChange(final Changer.ChangeMode mode) {
	if (mode == ChangeMode.SET) {
		return CollectionUtils.array(ItemStack.class);
	}
	return null;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:8,代码来源:ExprArmorStandItemHelmet.java


示例20: change

import ch.njol.skript.classes.Changer.ChangeMode; //导入依赖的package包/类
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
	assert mode == ChangeMode.RESET;
	
	final Chunk[] cs = getArray(e);
	for (final Chunk c : cs)
		c.getWorld().regenerateChunk(c.getX(), c.getZ());
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:9,代码来源:ExprChunk.java



注:本文中的ch.njol.skript.classes.Changer.ChangeMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AbstractManager类代码示例发布时间:2022-05-22
下一篇:
Java LoadTextUtil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap