Advertisement
lLuffy

Untitled

Jul 19th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. /**
  2. * Copyright (C) 2016 Chikachi
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License as
  6. * published by the Free Software Foundation, either version 3 of the
  7. * License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Affero General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Affero General Public License
  15. * along with this program. If not, see http://www.gnu.org/licenses.
  16. */
  17.  
  18. package chikachi.discord.command;
  19.  
  20. import chikachi.discord.DiscordClient;
  21. import net.dv8tion.jda.entities.User;
  22. import net.minecraft.command.ICommandSender;
  23. import net.minecraft.server.MinecraftServer;
  24. import net.minecraft.util.ChatComponentText;
  25. import net.minecraft.util.ChunkCoordinates;
  26. import net.minecraft.util.IChatComponent;
  27. import net.minecraft.world.World;
  28.  
  29. public class DiscordCommandSender implements ICommandSender {
  30. private final User user;
  31.  
  32. public DiscordCommandSender(User user) {
  33. this.user = user;
  34. }
  35.  
  36. @Override
  37. public String getCommandSenderName() {
  38. return "@" + this.user.getUsername();
  39. }
  40.  
  41. @Override
  42. public IChatComponent func_145748_c_() {
  43. return new ChatComponentText(this.getCommandSenderName());
  44. }
  45.  
  46. @Override
  47. public void addChatMessage(IChatComponent component) {
  48. DiscordClient.getInstance().sendMessage(component.getUnformattedText());
  49. }
  50.  
  51. @Override
  52. public boolean canCommandSenderUseCommand(int permLevel, String commandName) {
  53. return true;
  54. }
  55.  
  56. @Override
  57. public ChunkCoordinates getPlayerCoordinates() {
  58. return MinecraftServer.getServer().getPlayerCoordinates();
  59. }
  60.  
  61. @Override
  62. public World getEntityWorld() {
  63. return MinecraftServer.getServer().worldServers[0];
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement