mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 09:15:38 +00:00
make discord chat toggleable from in-game
This commit is contained in:
parent
0e63857ae0
commit
cde24b748a
@ -0,0 +1,22 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Toggle the display of Discord messages in-game.", usage = "/<command>", aliases = "tdiscord,tdisc")
|
||||||
|
public class Command_togglediscord extends FreedomCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
PlayerData data = plugin.pl.getData(playerSender);
|
||||||
|
data.setDiscordDisplay(!data.isDiscordDisplay());
|
||||||
|
plugin.pl.save(data);
|
||||||
|
msg("Discord message will " + (data.isDiscordDisplay() ? "now" : "no longer") + " be shown.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,17 @@
|
|||||||
package me.totalfreedom.totalfreedommod.discord;
|
package me.totalfreedom.totalfreedommod.discord;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Title;
|
import me.totalfreedom.totalfreedommod.rank.Title;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class DiscordToMinecraftListener extends ListenerAdapter
|
public class DiscordToMinecraftListener extends ListenerAdapter
|
||||||
{
|
{
|
||||||
@ -27,7 +30,14 @@ public class DiscordToMinecraftListener extends ListenerAdapter
|
|||||||
message += " " + tag;
|
message += " " + tag;
|
||||||
}
|
}
|
||||||
message += " " + ChatColor.RED + ChatColor.stripColor(member.getEffectiveName()) + ChatColor.DARK_GRAY + ": " + ChatColor.RESET + ChatColor.stripColor(event.getMessage().getContentDisplay());
|
message += " " + ChatColor.RED + ChatColor.stripColor(member.getEffectiveName()) + ChatColor.DARK_GRAY + ": " + ChatColor.RESET + ChatColor.stripColor(event.getMessage().getContentDisplay());
|
||||||
FUtil.bcastMsg(message);
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (TotalFreedomMod.getPlugin().pl.getData(player).isDiscordDisplay())
|
||||||
|
{
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FLog.info(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
@ -49,6 +48,9 @@ public class PlayerData
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private int totalVotes;
|
private int totalVotes;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean discordDisplay = true;
|
||||||
|
|
||||||
public PlayerData(ResultSet resultSet)
|
public PlayerData(ResultSet resultSet)
|
||||||
{
|
{
|
||||||
@ -71,6 +73,7 @@ public class PlayerData
|
|||||||
items.clear();
|
items.clear();
|
||||||
items.addAll(FUtil.stringToList(resultSet.getString("items")));
|
items.addAll(FUtil.stringToList(resultSet.getString("items")));
|
||||||
totalVotes = resultSet.getInt("total_votes");
|
totalVotes = resultSet.getInt("total_votes");
|
||||||
|
discordDisplay = resultSet.getBoolean("discord_display");
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
@ -103,6 +106,7 @@ public class PlayerData
|
|||||||
.append("- Has Verification: ").append(verification).append("\n")
|
.append("- Has Verification: ").append(verification).append("\n")
|
||||||
.append("- Coins: ").append(coins).append("\n")
|
.append("- Coins: ").append(coins).append("\n")
|
||||||
.append("- Total Votes: ").append(totalVotes).append("\n")
|
.append("- Total Votes: ").append(totalVotes).append("\n")
|
||||||
|
.append("- Discord Display: ").append(discordDisplay).append("\n")
|
||||||
.append("- Tag: ").append(FUtil.colorize(tag)).append(ChatColor.GRAY).append("\n")
|
.append("- Tag: ").append(FUtil.colorize(tag)).append(ChatColor.GRAY).append("\n")
|
||||||
.append("- Ride Mode: ").append(rideMode).append("\n")
|
.append("- Ride Mode: ").append(rideMode).append("\n")
|
||||||
.append("- Backup Codes: ").append(backupCodes.size()).append("/10").append("\n");
|
.append("- Backup Codes: ").append(backupCodes.size()).append("/10").append("\n");
|
||||||
@ -240,6 +244,7 @@ public class PlayerData
|
|||||||
put("coins", coins);
|
put("coins", coins);
|
||||||
put("items", FUtil.listToString(items));
|
put("items", FUtil.listToString(items));
|
||||||
put("total_votes", totalVotes);
|
put("total_votes", totalVotes);
|
||||||
|
put("discord_display", discordDisplay);
|
||||||
}};
|
}};
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user