Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Copyright (C) 2016 Chikachi
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see http://www.gnu.org/licenses.
- */
- package chikachi.discord.command;
- import chikachi.discord.DiscordClient;
- import net.dv8tion.jda.entities.User;
- import net.minecraft.command.ICommandSender;
- import net.minecraft.server.MinecraftServer;
- import net.minecraft.util.ChatComponentText;
- import net.minecraft.util.ChunkCoordinates;
- import net.minecraft.util.IChatComponent;
- import net.minecraft.world.World;
- public class DiscordCommandSender implements ICommandSender {
- private final User user;
- public DiscordCommandSender(User user) {
- this.user = user;
- }
- @Override
- public String getCommandSenderName() {
- return "@" + this.user.getUsername();
- }
- @Override
- public IChatComponent func_145748_c_() {
- return new ChatComponentText(this.getCommandSenderName());
- }
- @Override
- public void addChatMessage(IChatComponent component) {
- DiscordClient.getInstance().sendMessage(component.getUnformattedText());
- }
- @Override
- public boolean canCommandSenderUseCommand(int permLevel, String commandName) {
- return true;
- }
- @Override
- public ChunkCoordinates getPlayerCoordinates() {
- return MinecraftServer.getServer().getPlayerCoordinates();
- }
- @Override
- public World getEntityWorld() {
- return MinecraftServer.getServer().worldServers[0];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement