本文整理汇总了Java中org.spongepowered.api.text.title.Title类的典型用法代码示例。如果您正苦于以下问题:Java Title类的具体用法?Java Title怎么用?Java Title使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Title类属于org.spongepowered.api.text.title包,在下文中一共展示了Title类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerJoin
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
@Listener(order=Order.FIRST)
public void onPlayerJoin(final ClientConnectionEvent.Join event) {
EPlayer player = this.plugin.getEServer().getEPlayer(event.getTargetEntity());
// Corrige bug
player.sendTitle(Title.CLEAR);
player.getTabList().setHeaderAndFooter(null, null);
this.plugin.getManagerService().getEScoreBoard().addPlayer(player);
// Newbie
if (player.getFirstDatePlayed() == player.getLastDatePlayed()) {
player.setSpawnNewbie(true);
player.setTransform(player.getSpawn());
}
}
示例2: reload
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
public void reload() {
this.stop();
HashMap<UUID, TitleMessage> titleMessages = new HashMap<UUID, TitleMessage>(this.players);
this.players.clear();
for (Entry<UUID, TitleMessage> titleMessage : titleMessages.entrySet()) {
Optional<EPlayer> player = this.plugin.getEServer().getEPlayer(titleMessage.getKey());
if (player.isPresent()) {
player.get().sendTitle(Title.CLEAR);
// Event
this.postRemove(player.get(), titleMessage.getValue());
}
}
}
示例3: send
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
@Override
public boolean send(EPlayer player, String identifier, int priority, Title title) {
TitleMessage titleMessage = this.players.get(player.getUniqueId());
// Vérifie la priorité
if (titleMessage == null || this.getPriority(titleMessage.getIdentifier()) <= priority) {
TitleMessage newtitleMessage = new TitleMessage(player.getUniqueId(), identifier, title);
// Si l'ActionBar fonctionne
if (newtitleMessage.send(player)) {
// On ajoute la nouveau Title
this.players.put(player.getUniqueId(), newtitleMessage);
// Si il y a un déjà une Title on post un event de remplacement
if (titleMessage == null) {
this.postAdd(player, newtitleMessage);
} else {
this.postReplace(player, titleMessage, newtitleMessage);
}
// On réactive le cooldown
start();
return true;
}
}
return false;
}
示例4: handle
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
@Override
public void handle(Join joinEvent) throws Exception {
Player player = joinEvent.getTargetEntity();
String name = player.getName();
if (!Iterables.isEmpty(newsRepository.getAllNews())
&& player.hasPermission(NewsCommand.READ_PERMISSION)) {
player.sendTitle(
Title.builder().fadeIn(60).stay(500).fadeOut(100)
.title(Text.of(TextColors.WHITE, name, ", ", TextColors.GOLD, "you've got NEWS!"))
.subtitle(Text.builder("Type /news to see what's new on this server")
// .subtitle(Text.builder("Type /news to see what's changed on this server since you were last here..")
// onClick() doesn't seem to work (yet?) for (sub)title, but it doesn't do any harm to already put it
.onClick(TextActions.suggestCommand("/news"))
.build())
.build()
);
}
}
示例5: onStart
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
@Listener
public void onStart(GameInitializationEvent event) {
this.logger.info("TestCommand plugin enabled!");
Sponge.getCommandManager().register(this, CommandSpec.builder()
.executor((src, args) -> {
final Text message = Text.of(TextColors.GREEN, TextStyles.UNDERLINE, "Test", TextStyles.RESET, " 1234");
if (src instanceof Player) {
((Player) src).sendTitle(Title.builder().subtitle(message).build());
} else {
src.sendMessage(message);
}
return CommandResult.success();
})
.build(), "test-command", "tc");
}
示例6: createValue
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
private static CacheValue createValue(Title title) {
final ImmutableList.Builder<Message> builder = ImmutableList.builder();
if (title.isClear()) {
builder.add(new MessagePlayOutTitle.Clear());
}
if (title.isReset()) {
builder.add(new MessagePlayOutTitle.Reset());
}
final Optional<Integer> fadeIn = title.getFadeIn();
final Optional<Integer> stay = title.getStay();
final Optional<Integer> fadeOut = title.getFadeOut();
if (fadeIn.isPresent() || stay.isPresent() || fadeOut.isPresent()) {
builder.add(new MessagePlayOutTitle.SetTimes(fadeIn.orElse(20), stay.orElse(60), fadeOut.orElse(20)));
}
if (title.getTitle().isPresent() || title.getSubtitle().isPresent() || title.getActionBar().isPresent()) {
return new LocaleCacheValue(builder.build(), title);
} else {
return new CacheValue(builder.build());
}
}
示例7: getMessages
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
@Override
public List<Message> getMessages(Locale locale) {
return this.cache.computeIfAbsent(locale, locale0 -> {
Title title = this.title.get();
if (title == null) {
return Collections.emptyList();
}
final ImmutableList.Builder<Message> builder = ImmutableList.<Message>builder();
builder.addAll(this.messages);
Optional<Text> text = title.getTitle();
if (text.isPresent()) {
builder.add(new MessagePlayOutTitle.SetTitle(new LocalizedText(text.get(), locale)));
}
text = title.getSubtitle();
if (text.isPresent()) {
builder.add(new MessagePlayOutTitle.SetSubtitle(new LocalizedText(text.get(), locale)));
}
text = title.getActionBar();
if (text.isPresent()) {
builder.add(new MessagePlayOutTitle.SetActionbarTitle(new LocalizedText(text.get(), locale)));
}
return builder.build();
});
}
示例8: onPlayerJoin
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event) {
Player player = event.getTargetEntity();
String name = player.getName();
logger.info("onPlayerJoin: {} ", name);
// Human professor = spawnHuman(player);
// TODO urgh! Fix this later...
//staticProfessor = professor;
// TODO welcome BACK - long time no see since lastPlayed()
LiteralText text = Text.builder("Welcome ").color(TextColors.GOLD).append(Text.of(name))
.color(TextColors.DARK_GREEN).append(Text.of("! Try /question <friend>")).build();
player.sendMessage(text);
Title title = Title.builder().fadeIn(40).fadeOut(80).title(Text.builder("Welcome back!").build()).build();
player.sendTitle(title);
}
示例9: save
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
@Override
public void save(UltimateUser user, Boolean data) {
if (data) {
//Make sure the player is not un-afked instantly
AfkDetectionListener.afktime.put(user.getIdentifier(), 0L);
if (user.getPlayer().isPresent()) {
user.offer(AfkKeys.LAST_LOCATION, new Transform<>(user.getPlayer().get().getLocation(), user.getPlayer().get().getRotation(), user.getPlayer().get().getScale()));
}
} else {
//Player is no longer afk
if (user.getPlayer().isPresent()) {
user.getPlayer().get().sendTitle(Title.builder().clear().title(Text.EMPTY).subtitle(Text.EMPTY).build());
}
//Make sure the player is not afked instantly
AfkDetectionListener.afktime.put(user.getIdentifier(), System.currentTimeMillis());
}
}
示例10: discover
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
private void discover(Player player, Region region) {
// How exciting.
try (Connection connection = DriverManager.getConnection("jdbc:sqlite:" + databasePath);
PreparedStatement statement = connection.prepareStatement(DISCOVER_REGION)) {
statement.setString(1, player.getUniqueId().toString());
statement.setString(2, region.getUuid().toString());
statement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
return;
}
player.sendTitle(Title.builder()
.subtitle(Text.builder()
.color(TextColors.YELLOW)
.append(Text.of("- " + region.getName().toLowerCase(Locale.ENGLISH) + " discovered -"))
.build())
.fadeIn(20)
.stay(40)
.fadeOut(20)
.build());
SortedSet<Region> updated = discoveredBy.get(player.getUniqueId());
updated.add(region);
discoveredBy.replace(player.getUniqueId(), updated);
}
示例11: send
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
public void send(EFormat prefix, EPlayer player, Map<Pattern, EReplace<?>> replaces) {
Text title = Text.EMPTY;
if (!this.message.isEmpty()) {
if (this.prefix) {
title = prefix.toText().toText().concat(this.message.toText(replaces));
} else {
title = this.message.toText(replaces);
}
}
Text sub_title = Text.EMPTY;
if (!this.sub_message.isEmpty()) {
if (this.sub_prefix) {
sub_title = prefix.toText().toText().concat(this.sub_message.toText(replaces));
} else {
sub_title = this.sub_message.toText(replaces);
}
}
player.sendTitle(Title.builder()
.title(title)
.subtitle(sub_title)
.fadeIn(this.fadeIn)
.fadeOut(this.fadeOut)
.stay(this.stay)
.build());
}
示例12: remove
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
@Override
public boolean remove(EPlayer player, String identifier) {
TitleMessage titleMessage = this.players.get(player.getUniqueId());
if (titleMessage != null && titleMessage.getIdentifier().equalsIgnoreCase(identifier)) {
player.sendTitle(Title.CLEAR);
// Event
this.postRemove(player, titleMessage);
return true;
}
return false;
}
示例13: TitleEvent
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
public TitleEvent(EPlayer player, Action action, String identifier, Title title, long time, Cause cause) {
super();
this.player = player;
this.action = action;
this.identifier = identifier;
this.title = title;
this.time = time;
this.cause = cause;
}
示例14: Replace
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
public Replace(EPlayer player, String identifier, Title title, long time,
String newIdentifier, Title newTitle, long newTime, Cause cause) {
super(player, Action.REPLACE, identifier, title, time, cause);
this.newIdentifier = newIdentifier;
this.newTitle = newTitle;
this.newTime = newTime;
}
示例15: send
import org.spongepowered.api.text.title.Title; //导入依赖的package包/类
@Override
public void send(@Nullable Object sender, Text original, ChatType type) {
checkNotNull(original, "original text");
checkNotNull(type, "type");
for (MessageReceiver member : this.getMembers()) {
if (member instanceof ChatTypeMessageReceiver) {
this.transformMessage(sender, member, original, type).ifPresent(text -> ((ChatTypeMessageReceiver) member).sendMessage(type, text));
} else {
this.transformMessage(sender, member, original, type).ifPresent(member::sendMessage);
}
if (member instanceof Player) {
Player player = (Player) member;
boolean p = sender instanceof Player;
Player s = p ? (Player) sender : null;
if ((getConfig().sound.play || getConfig().title.use) &&
((!p || (s.hasPermission("boop.use." + player.getName()) || !getConfig().restricted.contains(player.getName())))
&& (textContainsAny(original, getPlayerMatches(player))
|| textContainsAny(original, applyPrefixes(getGroupNames(player).stream()
.filter(t -> !p || (s.hasPermission("boop.use." + t) || !getConfig().restricted.contains(t)))
.collect(Collectors.toList())))))) {
if (getConfig().sound.play) {
player.playSound(getConfig().sound.sound, player.getLocation().getPosition(), 10.0);
}
if (getConfig().title.use) {
player.sendTitle(Title.builder().subtitle(getConfig().title.text).fadeIn(20).fadeOut(20).stay(40).build());
}
}
}
}
}