本文整理匯總了Java中org.spongepowered.api.event.network.ClientConnectionEvent.Join方法的典型用法代碼示例。如果您正苦於以下問題:Java ClientConnectionEvent.Join方法的具體用法?Java ClientConnectionEvent.Join怎麽用?Java ClientConnectionEvent.Join使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.spongepowered.api.event.network.ClientConnectionEvent
的用法示例。
在下文中一共展示了ClientConnectionEvent.Join方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPlayerJoin
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event, @Root Player player) {
Date now = new Date(java.util.Date.from(Instant.now()).getTime());
UserData userData = dataStore.getOrCreateUserData(player);
int index[] = new int[1];
dataStore.getPlayerRegions(player.getUniqueId()).forEach(region -> {
if (region.getType() == LoadedRegion.ChunkType.PERSONAL)
region.forceChunks();
index[0]++;
});
logger.info(String.format("Loaded %s chunks for %s", index[0], player.getName()));
// Update the userData in case it's an existing userData
dataStore.getOrCreateUserData(player).setLastSeen(now).update();
database.saveUserData(userData);
}
示例2: onPlayerJoin
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event, @Root Player player) {
if (!player.hasPermission("iplog.bypasslogging")) {
final Storage storage = IPLog.getPlugin().getStorage();
final InetAddress ip = player.getConnection().getAddress().getAddress();
final UUID uuid = player.getUniqueId();
final LocalDateTime time = LocalDateTime.now();
if (storage.isPresent(ip, uuid)) {
storage.updateConnection(ip, uuid, time);
} else {
storage.addConnection(ip, uuid, time);
}
}
}
示例3: joined
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener(order=Order.FIRST)
public void joined(ClientConnectionEvent.Join event) {
Player player = event.getTargetEntity();
Collection<ProfileProperty> props = player.getProfile().getPropertyMap().get("language");
Locale checkload = null;
for (ProfileProperty prop : props)
if (prop.getName().equalsIgnoreCase("language")) {
playerLang.put(player.getProfile().getUniqueId(), checkload=Locale.forLanguageTag(prop.getValue().replace('_', '-')));
break;
}
//use geo location in the future? player.getLocale seems to stick to en_US
if (checkload==null)
playerLang.put(player.getProfile().getUniqueId(), checkload=player.getLocale());
loadLang(checkload);
}
示例4: onClientConnection
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener
public void onClientConnection(ClientConnectionEvent.Join event) {
Player player = event.getTargetEntity();
UUID uuid = player.getUniqueId();
ConfigurationNode node = PlayerList.getInstance().getNode();
if (node.getNode("players", uuid, "pvp").isVirtual()) {
node.getNode("players", uuid, "pvp").setValue(false);
PlayerList.getInstance().save();
player.sendMessage(TranslationHelper.t("text.player.disabled", player.getLocale()));
player.sendMessage(TranslationHelper.t("text.player.toggle", player.getLocale()));
} else {
if (node.getNode("players", uuid, "pvp").getBoolean()) {
player.sendMessage(TranslationHelper.t("text.player.enabled", player.getLocale()));
player.sendMessage(TranslationHelper.t("text.player.toggle", player.getLocale()));
} else {
player.sendMessage(TranslationHelper.t("text.player.disabled", player.getLocale()));
player.sendMessage(TranslationHelper.t("text.player.toggle", player.getLocale()));
}
}
}
示例5: onPlayerJoin
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener
public void onPlayerJoin(final ClientConnectionEvent.Join event) {
Player player = event.getTargetEntity();
// Create/load config
Bedrock.getPlayerConfigManager().loadPlayer(player);
// Is brand new?
if (player.get(Keys.FIRST_DATE_PLAYED).get().equals(player.get(Keys.LAST_DATE_PLAYED).get())) {
// Force spawn position because vanilla has a "fuzz" radius around spawn
Location<World> spawn = player.getWorld().getLocation(player.getWorld().getProperties().getSpawnPosition());
player.setLocation(spawn);
MessageChannel.TO_ALL.send(Text.of(TextColors.GOLD, "Welcome ", TextColors.LIGHT_PURPLE,
player.getName(),TextColors.GOLD, " to DHMC!"));
}
}
示例6: onPlayerJoin
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event) {
Player player = event.getTargetEntity();
NamelessPlugin.LOGIN_TIME.put(player.getUniqueId(), System.currentTimeMillis());
NamelessPlugin.getGame().getScheduler().createAsyncExecutor(NamelessPlugin.getInstance()).execute(() -> {
NamelessPlayer namelessPlayer = new NamelessPlayer(player.getUniqueId(), NamelessPlugin.baseApiURL);
if (namelessPlayer.exists()) {
if (namelessPlayer.isValidated()) {
// Only show notifications if the player has validated their account
userGetNotifications(player);
} else {
// If the player has not validated their account they get informed.
player.sendMessage(Message.ACCOUNT_NOT_VALIDATED.getMessage());
}
userGroupSync(player);
}
});
}
示例7: onPlayerJoin
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event){
Player player = event.getTargetEntity();
if(!plugin.getAPIUrl().isEmpty()){
try {
userFileCheck(player);
userNameCheck(player);
} catch (IOException e) {
e.printStackTrace();
}
userGetNotification(player);
userGroupSync(player);
}
}
示例8: onPlayerJoin
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的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());
}
}
示例9: onLogin
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener
public void onLogin(ClientConnectionEvent.Join event, @Getter("getTargetEntity") Player player) {
if (!isApplicable(player)) {
return;
}
Optional<WorldService> optWorldService = Sponge.getServiceManager().provide(WorldService.class);
if (!optWorldService.isPresent()) {
return;
}
WorldService worldService = optWorldService.get();
Collection<World> worlds = worldService.getEffectWrapper(MainWorldWrapper.class).get().getWorlds();
player.setLocation(worlds.iterator().next().getSpawnLocation());
}
示例10: onPlayerJoin
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event) {
try (Connection con = SQLHandle.getConnection()) {
DSLContext create = DSL.using(con);
Player player = event.getTargetEntity();
UUID uuid = player.getUniqueId();
World world = player.getWorld();
Record1<Timestamp> result = create.select(WORLDS.CREATED_AT).from(WORLDS).where(WORLDS.NAME.equal(world.getName())).fetchOne();
Timestamp worldCreationTimestamp = result.getValue(WORLDS.CREATED_AT);
long worldCreationTime = 0;
if (worldCreationTimestamp != null) {
worldCreationTime = worldCreationTimestamp.getTime();
}
if (worldCreationTime > lastPlayerLogin.remove(uuid)) {
Location<World> spawn = getEffectWrapper(MainWorldWrapper.class).get().getPrimaryWorld().getSpawnLocation();
player.setLocation(spawn);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
示例11: onPlayerJoin
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的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);
}
示例12: onPlayerJoinEvent
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener
public void onPlayerJoinEvent(ClientConnectionEvent.Join event) {
if (event.getTargetEntity().hasPermission("buycraft.admin") && !upToDate) {
plugin.getPlatform().executeAsyncLater(() -> {
try {
event.getTargetEntity().sendMessage(
Text.builder()
.append(Text.of(plugin.getI18n().get("update_available", lastKnownVersion.getVersion())))
.onClick(TextActions.openUrl(new URL("https://server.buycraft.net")))
.color(TextColors.YELLOW)
.build());
} catch (MalformedURLException e) {
throw new AssertionError(e); // seriously?
}
}, 3, TimeUnit.SECONDS);
}
}
示例13: onJoin
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener
public void onJoin(ClientConnectionEvent.Join event)
{
Player player = event.getTargetEntity();
MultiverseData data = player.get(MultiverseData.class).orElse(new MultiverseData(null, new HashMap<>()));
World world = player.getWorld();
String loginUniverse = module.getUniverse(world);
if (data.getCurrentUniverse() == null)
{
data.setCurrentUniverse(loginUniverse); // set universe
}
else if (!data.getCurrentUniverse().equals(loginUniverse)) // Player is not in the expected universe
{
data.setCurrentUniverse(loginUniverse); // update universe
data.from(loginUniverse, world, player).applyToPlayer(player); // load playerdata
}
player.offer(data);
}
示例14: onJoin
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener
public void onJoin(ClientConnectionEvent.Join event)
{
Player player = event.getTargetEntity();
String prefix = player.getOption("tablist-prefix").orElse("");
if (this.config.header != null && !this.config.header.isEmpty())
{
player.getTabList().setHeader(FORMATTING_CODE.deserialize(this.config.header));
}
for (Player p : Sponge.getServer().getOnlinePlayers())
{
Optional<TabListEntry> entry = p.getTabList().getEntry(player.getUniqueId());
entry.ifPresent(tle -> tle.setDisplayName(FORMATTING_CODE.deserialize(prefix + player.getName())));
String pPrefix = p.getOption("tablist-prefix").orElse("");
Optional<TabListEntry> pEntry = player.getTabList().getEntry(p.getUniqueId());
pEntry.ifPresent(tle -> tle.setDisplayName(FORMATTING_CODE.deserialize(pPrefix + p.getName())));
}
}
示例15: onJoin
import org.spongepowered.api.event.network.ClientConnectionEvent; //導入方法依賴的package包/類
@Listener
public void onJoin(ClientConnectionEvent.Join event)
{
Player player = event.getTargetEntity();
if (module.isHidden(player))
{
module.hidePlayer(player, true);
}
if (player.hasPermission(module.perms().AUTO_HIDE.getId()))
{
event.setMessageCancelled(true);
module.hidePlayer(player, true);
i18n.send(player, POSITIVE, "You were automatically hidden!");
}
}