当前位置: 首页>>代码示例>>Java>>正文


Java ChangeMode类代码示例

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


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


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