本文整理汇总了Java中in.twizmwaz.cardinal.event.objective.ObjectiveTouchEvent类的典型用法代码示例。如果您正苦于以下问题:Java ObjectiveTouchEvent类的具体用法?Java ObjectiveTouchEvent怎么用?Java ObjectiveTouchEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectiveTouchEvent类属于in.twizmwaz.cardinal.event.objective包,在下文中一共展示了ObjectiveTouchEvent类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockPlace
import in.twizmwaz.cardinal.event.objective.ObjectiveTouchEvent; //导入依赖的package包/类
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (!isComplete()) {
if (monument.contains(event.getBlock()) && partOfObjective(event.getBlockPlaced())) {
if (Teams.getTeamByPlayer(event.getPlayer()).orNull() != team) {
ChatUtil.sendWarningMessage(event.getPlayer(), new LocalizedChatMessage(ChatConstant.ERROR_ENEMY_OBJECTIVE));
event.setCancelled(true);
} else if (!isRepairable()) {
ChatUtil.sendWarningMessage(event.getPlayer(), new LocalizedChatMessage(ChatConstant.ERROR_REPAIR_OBJECTIVE));
event.setCancelled(true);
} else {
complete--;
ObjectiveTouchEvent touchEvent = new ObjectiveTouchEvent(this, null, false);
Bukkit.getServer().getPluginManager().callEvent(touchEvent);
}
}
}
}
示例2: addBrokenPiecesFor
import in.twizmwaz.cardinal.event.objective.ObjectiveTouchEvent; //导入依赖的package包/类
/**
* Breaks a number of pieces for a certain player. This will automatically show touch messages, and complete the
* monument if it reaches completion percentage.
* @param player The player that touched.
* @param contribution The amount of pieces this player broke.
*/
public void addBrokenPiecesFor(Player player, int contribution) {
CompetitorContainer container = match.getPlayingContainer(player);
if (!isCompleted() && container instanceof Team) {
Team team = (Team) container;
setTouched(team);
if (show && !touchedPlayers.contains(player)) {
touchedPlayers.add(player);
Channels.getTeamChannel(match, team).sendPrefixedMessage(
new LocalizedComponent(ChatConstant.getConstant("objective.destroyable.touched"),
new TeamComponent(owner),
new UnlocalizedComponent(name),
new NameComponent(player)
)
);
}
UUID uuid = player.getUniqueId();
playerContributions.putIfAbsent(uuid, 0);
playerContributions.put(uuid, playerContributions.get(uuid) + contribution);
broken += contribution;
if ((double) broken / total >= completion) {
completed = true;
Channels.getGlobalChannel(match.getMatchThread()).sendMessage(
new LocalizedComponentBuilder(
ChatConstant.getConstant("objective.destroyable.completed"),
new TeamComponent(owner),
new UnlocalizedComponent(name),
getContributionList()
).build()
);
Bukkit.getPluginManager().callEvent(new ObjectiveCompleteEvent(this, player));
} else {
Bukkit.getPluginManager().callEvent(new ObjectiveTouchEvent(this, player));
}
entryHolder.updateEntries();
}
}
示例3: onWoolTouch
import in.twizmwaz.cardinal.event.objective.ObjectiveTouchEvent; //导入依赖的package包/类
@EventHandler
public void onWoolTouch(ObjectiveTouchEvent event) {
if (event.getObjective().equals(this) && event.displayTouchMessage() && !this.receivedSnowflakes.contains(event.getPlayer().getUniqueId())) {
Bukkit.getServer().getPluginManager().callEvent(new SnowflakeChangeEvent(event.getPlayer(), Snowflakes.ChangeReason.WOOL_TOUCH, 8, MiscUtils.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.GRAY));
receivedSnowflakes.add(event.getPlayer().getUniqueId());
}
}
示例4: onObjectiveTouch
import in.twizmwaz.cardinal.event.objective.ObjectiveTouchEvent; //导入依赖的package包/类
@EventHandler
public void onObjectiveTouch(ObjectiveTouchEvent event) {
if (event.getObjective().showOnScoreboard() && event.displayTouchMessage()) {
if (event.getObjective() instanceof WoolObjective) {
log(new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PICKED_FOR, event.getPlayer().getName(), event.getObjective().getName().toUpperCase().replaceAll("_", " "), TeamUtils.getTeamByPlayer(event.getPlayer()).getName()).getMessage(Locale.getDefault().toString()));
} else if (event.getObjective() instanceof CoreObjective) {
log(new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_TOUCHED_FOR, event.getPlayer().getName(), event.getObjective().getName(), TeamUtils.getTeamByPlayer(event.getPlayer()).getName()).getMessage(Locale.getDefault().toString()));
} else if (event.getObjective() instanceof DestroyableObjective) {
log(new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_DAMAGED_FOR, event.getPlayer().getName(), event.getObjective().getName(), TeamUtils.getTeamByPlayer(event.getPlayer()).getName()).getMessage(Locale.getDefault().toString()));
}
}
}
示例5: onWoolPickup
import in.twizmwaz.cardinal.event.objective.ObjectiveTouchEvent; //导入依赖的package包/类
@EventHandler
public void onWoolPickup(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
if (!this.complete && GameHandler.getGameHandler().getMatch().isRunning()) {
try {
if (event.getCurrentItem().getType().equals(Material.WOOL) && ((Wool) event.getCurrentItem().getData()).getColor().equals(color)) {
if (Teams.getTeamByPlayer(player).orNull() == team) {
boolean touchMessage = false;
if (!this.playersTouched.contains(player.getUniqueId())) {
this.playersTouched.add(player.getUniqueId());
if (this.show && !this.complete) {
Teams.getTeamChannel(Optional.of(team)).sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.WHITE + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PICKED_FOR, team.getColor() + player.getName() + ChatColor.WHITE, MiscUtil.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.WHITE, team.getCompleteName() + ChatColor.WHITE)));
for (Player player1 : Bukkit.getOnlinePlayers()) {
if (Teams.getTeamByPlayer(player1).isPresent() && Teams.getTeamByPlayer(player1).get().isObserver()) {
player1.sendMessage(new UnlocalizedChatMessage(ChatColor.GRAY + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PICKED_FOR, team.getColor() + player.getName() + ChatColor.GRAY, MiscUtil.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.GRAY, team.getCompleteName() + ChatColor.GRAY)).getMessage(player1.getLocale()));
}
}
touchMessage = true;
}
}
if (!touched) touched = true;
ObjectiveTouchEvent touchEvent = new ObjectiveTouchEvent(this, player, touchMessage);
Bukkit.getServer().getPluginManager().callEvent(touchEvent);
}
}
} catch (NullPointerException e) {
}
}
}
示例6: onWoolPickup
import in.twizmwaz.cardinal.event.objective.ObjectiveTouchEvent; //导入依赖的package包/类
@EventHandler
public void onWoolPickup(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
if (!this.complete && GameHandler.getGameHandler().getMatch().isRunning()) {
try {
if (event.getCurrentItem().getType() == Material.WOOL && event.getCurrentItem().getData().getData() == color.getData()) {
if (TeamUtils.getTeamByPlayer(player) == team) {
boolean touchMessage = false;
if (!this.playersTouched.contains(player.getUniqueId())) {
this.playersTouched.add(player.getUniqueId());
if (this.show && !this.complete) {
TeamUtils.getTeamChannel(team).sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.GRAY + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PICKED, team.getColor() + player.getName() + ChatColor.GRAY, MiscUtils.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.GRAY)));
for (Player player1 : Bukkit.getOnlinePlayers()) {
if (TeamUtils.getTeamByPlayer(player1) != null && TeamUtils.getTeamByPlayer(player1).isObserver()) {
String message = new UnlocalizedChatMessage(ChatColor.GRAY + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PICKED_FOR, team.getColor() + player.getName() + ChatColor.GRAY, MiscUtils.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.GRAY, team.getCompleteName() + ChatColor.GRAY)).getMessage(player1.getLocale());
if (!team.getOriginalName().equalsIgnoreCase(team.getName())) {
message = message.replace(new LocalizedChatMessage(ChatConstant.MISC_THE).getMessage(player.getLocale()) + " ", "");
}
player1.sendMessage(message);
}
}
touchMessage = true;
}
}
boolean oldState = this.touched;
this.touched = true;
if (!oldState) {
if (location != null) {
proximity = location.distance(place.getVector());
} else {
proximity = player.getLocation().toVector().distance(place.getVector());
}
}
ObjectiveTouchEvent touchEvent = new ObjectiveTouchEvent(this, player, !oldState, touchMessage);
Bukkit.getServer().getPluginManager().callEvent(touchEvent);
}
}
} catch (NullPointerException e) {
}
}
}
示例7: onBlockBreak
import in.twizmwaz.cardinal.event.objective.ObjectiveTouchEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
if (!event.isCancelled()) {
if (getBlocks().contains(event.getBlock())) {
if (TeamUtils.getTeamByPlayer(event.getPlayer()) != team) {
boolean touchMessage = false;
if (!playersTouched.contains(event.getPlayer().getUniqueId())) {
playersTouched.add(event.getPlayer().getUniqueId());
TeamModule teamModule = TeamUtils.getTeamByPlayer(event.getPlayer());
TeamChannel channel = TeamUtils.getTeamChannel(teamModule);
if (this.show && !this.complete) {
channel.sendLocalizedMessage(new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_TOUCHED, teamModule.getColor() + event.getPlayer().getName() + ChatColor.GRAY, ChatColor.RED + name + ChatColor.GRAY));
for (Player player : Bukkit.getOnlinePlayers()) {
if (TeamUtils.getTeamByPlayer(player) != null && TeamUtils.getTeamByPlayer(player).isObserver()) {
String message = new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_DAMAGED_FOR, teamModule.getColor() + event.getPlayer().getName() + ChatColor.GRAY, ChatColor.AQUA + name + ChatColor.GRAY, teamModule.getCompleteName() + ChatColor.GRAY).getMessage(player.getLocale());
if (!teamModule.getOriginalName().equalsIgnoreCase(teamModule.getName())) {
message = message.replace(new LocalizedChatMessage(ChatConstant.MISC_THE).getMessage(player.getLocale()) + " ", "");
}
player.sendMessage(message);
}
}
touchMessage = true;
}
}
if (!playersCompleted.contains(event.getPlayer().getUniqueId())) playersCompleted.add(event.getPlayer().getUniqueId());
boolean oldState = this.touched;
this.touched = true;
ObjectiveTouchEvent touchEvent = new ObjectiveTouchEvent(this, event.getPlayer(), !oldState, touchMessage);
Bukkit.getServer().getPluginManager().callEvent(touchEvent);
event.setCancelled(false);
} else {
event.setCancelled(true);
if (this.show) ChatUtils.sendWarningMessage(event.getPlayer(), new LocalizedChatMessage(ChatConstant.ERROR_OWN_CORE));
return;
}
}
if (core.contains(event.getBlock())) {
if (TeamUtils.getTeamByPlayer(event.getPlayer()) == team) {
event.setCancelled(true);
if (this.show) ChatUtils.sendWarningMessage(event.getPlayer(), new LocalizedChatMessage(ChatConstant.ERROR_OWN_CORE));
}
}
}
}
示例8: onWoolTouch
import in.twizmwaz.cardinal.event.objective.ObjectiveTouchEvent; //导入依赖的package包/类
@EventHandler
public void onWoolTouch(ObjectiveTouchEvent event) {
if (event.getObjective().equals(this) && event.displayTouchMessage()) {
Bukkit.getServer().getPluginManager().callEvent(new SnowflakeChangeEvent(event.getPlayer(), Snowflakes.ChangeReason.WOOL_TOUCH, 8, MiscUtil.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.GRAY));
}
}
示例9: onTouchEvent
import in.twizmwaz.cardinal.event.objective.ObjectiveTouchEvent; //导入依赖的package包/类
@EventHandler
public void onTouchEvent(ObjectiveTouchEvent event) {
if (event.getObjective().equals(objective)) this.active = info.needsTouch;
}
示例10: onObjectiveTouch
import in.twizmwaz.cardinal.event.objective.ObjectiveTouchEvent; //导入依赖的package包/类
@EventHandler
public void onObjectiveTouch(ObjectiveTouchEvent event) {
updateObjectivePrefix(event.getObjective());
updateTeamOrder();
}
示例11: onBlockBreak
import in.twizmwaz.cardinal.event.objective.ObjectiveTouchEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
if (!event.isCancelled()) {
if (getBlocks().contains(event.getBlock())) {
if (Teams.getTeamByPlayer(event.getPlayer()).orNull() != team) {
boolean touchMessage = false;
if (!playersTouched.contains(event.getPlayer().getUniqueId())) {
playersTouched.add(event.getPlayer().getUniqueId());
Optional<TeamModule> teamModule = Teams.getTeamByPlayer(event.getPlayer());
if (teamModule.isPresent()) {
ChatChannel channel = Teams.getTeamChannel(teamModule);
if (this.show && !this.complete) {
channel.sendLocalizedMessage(new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_TOUCHED_FOR, teamModule.get().getColor() + event.getPlayer().getName() + ChatColor.WHITE, name, teamModule.get().getCompleteName() + ChatColor.WHITE));
for (Player player : Bukkit.getOnlinePlayers()) {
if (Teams.getTeamByPlayer(player).isPresent() && Teams.getTeamByPlayer(player).get().isObserver()) {
player.sendMessage(new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_TOUCHED_FOR, teamModule.get().getColor() + event.getPlayer().getName() + ChatColor.GRAY, ChatColor.RED + name + ChatColor.GRAY, teamModule.get().getCompleteName() + ChatColor.GRAY).getMessage(player.getLocale()));
}
}
touchMessage = true;
}
}
}
if (!playersCompleted.contains(event.getPlayer().getUniqueId()))
playersCompleted.add(event.getPlayer().getUniqueId());
this.touched = true;
ObjectiveTouchEvent touchEvent = new ObjectiveTouchEvent(this, event.getPlayer(), touchMessage);
Bukkit.getServer().getPluginManager().callEvent(touchEvent);
event.setCancelled(false);
} else {
event.setCancelled(true);
if (this.show)
ChatUtil.sendWarningMessage(event.getPlayer(), new LocalizedChatMessage(ChatConstant.ERROR_OWN_CORE));
return;
}
}
if (core.contains(event.getBlock())) {
if (Teams.getTeamByPlayer(event.getPlayer()).orNull() == team) {
event.setCancelled(true);
if (this.show)
ChatUtil.sendWarningMessage(event.getPlayer(), new LocalizedChatMessage(ChatConstant.ERROR_OWN_CORE));
}
}
}
}