Applied changes
This commit is contained in:
parent
dade15da53
commit
c336de27ea
2 changed files with 3 additions and 39 deletions
|
@ -4,8 +4,6 @@ import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -51,15 +49,15 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
return;
|
return;
|
||||||
if (event.getMessage().getContent().startsWith("/")) {
|
if (event.getMessage().getContent().startsWith("/")) {
|
||||||
final String cmd = event.getMessage().getContent().substring(1);
|
final String cmd = event.getMessage().getContent().substring(1);
|
||||||
Optional<? extends Player> str = Bukkit.getOnlinePlayers().stream().filter(p -> { // TODO: Support offline players
|
Optional<? extends Player> player = Bukkit.getOnlinePlayers().stream().filter(p -> { // TODO: Support offline players
|
||||||
DiscordPlayer dp = TBMCPlayer.getPlayerAs(p, DiscordPlayer.class); // Online player, already loaded
|
DiscordPlayer dp = TBMCPlayer.getPlayerAs(p, DiscordPlayer.class); // Online player, already loaded
|
||||||
return author.getID().equals(dp.getDiscordID());
|
return author.getID().equals(dp.getDiscordID());
|
||||||
}).findAny();
|
}).findAny();
|
||||||
try {
|
try {
|
||||||
if (str.isPresent()) // Connected?
|
if (player.isPresent()) // Connected?
|
||||||
{
|
{
|
||||||
if (!ConnectedSenders.containsKey(author.getID()))
|
if (!ConnectedSenders.containsKey(author.getID()))
|
||||||
ConnectedSenders.put(author.getID(), new DiscordPlayerSender(author, str.get()));
|
ConnectedSenders.put(author.getID(), new DiscordPlayerSender(author, player.get()));
|
||||||
final DiscordPlayerSender dsender = ConnectedSenders.get(author.getID());
|
final DiscordPlayerSender dsender = ConnectedSenders.get(author.getID());
|
||||||
dsender.setChannel(event.getMessage().getChannel());
|
dsender.setChannel(event.getMessage().getChannel());
|
||||||
// Execute as ingame player
|
// Execute as ingame player
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
package buttondevteam.discordplugin.mccommands;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
|
||||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
|
||||||
|
|
||||||
public class DiscordMCCommand extends TBMCCommandBase {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String GetCommandPath() {
|
|
||||||
return "discord";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] GetHelpText(String alias) {
|
|
||||||
return TBMCChatAPI.GetSubCommands(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean GetModOnly() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean GetPlayerOnly() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue