Created
April 24, 2017 16:04
-
-
Save ryantheleach/0ab39f10e1879fd04b0b2c7c4018f25d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package au.id.rleach.forumstest2; | |
import com.google.common.collect.Sets; | |
import com.google.inject.Inject; | |
import org.slf4j.Logger; | |
import org.spongepowered.api.Sponge; | |
import org.spongepowered.api.command.CommandException; | |
import org.spongepowered.api.command.CommandResult; | |
import org.spongepowered.api.command.CommandSource; | |
import org.spongepowered.api.command.args.CommandContext; | |
import org.spongepowered.api.command.args.GenericArguments; | |
import org.spongepowered.api.command.spec.CommandSpec; | |
import org.spongepowered.api.data.key.Keys; | |
import org.spongepowered.api.entity.living.player.Player; | |
import org.spongepowered.api.entity.living.player.tab.TabList; | |
import org.spongepowered.api.entity.living.player.tab.TabListEntry; | |
import org.spongepowered.api.event.Listener; | |
import org.spongepowered.api.event.filter.Getter; | |
import org.spongepowered.api.event.game.state.GameInitializationEvent; | |
import org.spongepowered.api.event.network.ClientConnectionEvent; | |
import org.spongepowered.api.plugin.Plugin; | |
import org.spongepowered.api.text.Text; | |
import org.spongepowered.api.text.channel.MessageChannel; | |
import org.spongepowered.api.text.format.TextColors; | |
import org.spongepowered.api.text.format.TextStyles; | |
import java.util.Optional; | |
import java.util.Set; | |
import java.util.UUID; | |
@Plugin( | |
id = "forumstest2", | |
name = "Forumstest2", | |
version = "1.0-SNAPSHOT" | |
) | |
public class Forumstest2 { | |
@Inject private Logger logger; | |
private Text playerKey = Text.of("player"); | |
@Listener public void onGameInitialization(GameInitializationEvent event) { | |
CommandSpec recordCommand = CommandSpec.builder() | |
.description(Text.of("Announces that you are recording.")) | |
.extendedDescription(Text.of("Appends to your tablist name (r), as well as announcing to chat")) | |
.arguments(GenericArguments.playerOrSource(playerKey)) | |
.executor(this::runCmd) | |
.build(); | |
Sponge.getCommandManager().register(this, recordCommand, "record"); | |
} | |
private CommandResult runCmd(CommandSource commandSource, CommandContext commandContext) throws CommandException { | |
Player player = commandContext.<Player>getOne(playerKey).get(); | |
int x = player.get(Keys.TOTAL_EXPERIENCE).get(); | |
player.sendMessage(Text.of(x)); | |
return CommandResult.success(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment