Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public void start(SingleApplication app) {
var bundle = getBundle(session);
Category finalCategory = category;
ChannelAction<TextChannel> action;
action = finalCategory == null ?game.getGuild().createTextChannel(MessageFormat.format(bundle.getString("TextChannel"),game.getId())):
finalCategory.createTextChannel(MessageFormat.format(bundle.getString("TextChannel"),game.getId()));
action = finalCategory == null ?game.getGuild().createTextChannel(String.format(bundle.getString("TextChannel"),game.getId())):
finalCategory.createTextChannel(String.format(bundle.getString("TextChannel"),game.getId()));
session.close();
action.queue((textChannel -> {
this.textChannelId = textChannel.getIdLong();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,12 @@ public void start(SingleApplication app) {
var guild = GuildEntity.get(session, game.getGuildId());
Category category = null;
if(guild.getGameEntity().getGameCategoryId() != null)
category = guild.getGameEntity().getGameCategory();
category = guild.getGameEntity().getGameCategory();
var bundle = getBundle(session);
Category finalCategory = category;
ChannelAction<TextChannel> action;
if(finalCategory == null)
action = game.getGuild().createTextChannel(MessageFormat.format(bundle.getString("TextChannel"),game.getId()));
else
action = finalCategory.createTextChannel(MessageFormat.format(bundle.getString("TextChannel"),game.getId()));
session.close();
action.queue((textChannel -> {
((finalCategory == null)?game.getGuild().createTextChannel(String.format(bundle.getString("TextChannel"),game.getId())):
finalCategory.createTextChannel(String.format(bundle.getString("TextChannel"),game.getId()))).queue((textChannel -> {
this.textChannelId = textChannel.getIdLong();
if(finalCategory != null)
textChannel.getManager().setParent(finalCategory).queue();
Expand Down Expand Up @@ -84,10 +80,10 @@ public void chooseNextPlayer(){
var session = Linwood.getInstance().getDatabase().getSessionFactory().openSession();
var bundle = getBundle(session);
sendLeaderboard(session);
getTextChannel().sendMessage(MessageFormat.format(bundle.getString("Next"), currentRound + 1)).queue(message -> {
getTextChannel().sendMessageFormat(bundle.getString("Next"), currentRound + 1).queue(message -> {
wantWriterMessageId = message.getIdLong();
message.addReaction("\uD83D\uDD90️").queue(aVoid ->
message.addReaction("⛔").queue());
message.addReaction("⛔").queue());
stopTimer();
timer.schedule(new TimerTask() {
@Override
Expand Down Expand Up @@ -117,7 +113,7 @@ public void nextRound(Session session, long writerId){
var bundle = getBundle(session);
game.getGuild().retrieveMemberById(writerId).queue(member -> {
var session1 = Linwood.getInstance().getDatabase().getSessionFactory().openSession();
getTextChannel().sendMessage(MessageFormat.format(bundle.getString("Round"), member.getAsMention())).queue();
getTextChannel().sendMessageFormat(bundle.getString("Round"), member.getAsMention()).queue();
sendLeaderboard(session1);
session1.close();
round.inputWriter();
Expand Down Expand Up @@ -164,7 +160,7 @@ public void finishRound(){
wantWriter.clear();
if(currentRound >= maxRounds) finishGame();
else
chooseNextPlayer();
chooseNextPlayer();
session.close();
});
}
Expand All @@ -182,16 +178,16 @@ private void sendLeaderboard(ResourceBundle bundle, TextChannel textChannel){
var leaderboard = getLeaderboard();
if(textChannel == null)
return;
textChannel.getGuild().retrieveMembersByIds(leaderboard.stream().map(Map.Entry::getKey).collect(Collectors.toList())).onSuccess(members -> {
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < members.size(); i++) {
var member = members.get(i);
if (member != null)
stringBuilder.append(MessageFormat.format(bundle.getString("Leaderboard"), i + 1,
member.getAsMention(), leaderboard.get(i).getValue()));
}
textChannel.sendMessage(new EmbedBuilder().setTitle(bundle.getString("LeaderboardHeader")).setDescription(stringBuilder.toString()).setFooter(bundle.getString("LeaderboardFooter")).build()).queue();
});
textChannel.getGuild().retrieveMembersByIds(leaderboard.stream().map(Map.Entry::getKey).collect(Collectors.toList())).onSuccess(members -> {
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < members.size(); i++) {
var member = members.get(i);
if (member != null)
stringBuilder.append(String.format(bundle.getString("Leaderboard"), i + 1,
member.getAsMention(), leaderboard.get(i).getValue()));
}
textChannel.sendMessage(new EmbedBuilder().setTitle(bundle.getString("LeaderboardHeader")).setDescription(stringBuilder.toString()).setFooter(bundle.getString("LeaderboardFooter")).build()).queue();
});
}

private ArrayList<Map.Entry<Long, Integer>> getLeaderboard() {
Expand Down Expand Up @@ -251,12 +247,12 @@ public boolean wantWriter(Session session, Member member) {
if(getRound() != null)
return false;
wantWriter.add(member.getIdLong());
getTextChannel().sendMessage(MessageFormat.format(getBundle(session).getString("Join"), member.getUser().getAsMention())).queue();
getTextChannel().sendMessageFormat(getBundle(session).getString("Join"), member.getUser().getAsMention()).queue();
return true;
}

public void removeWriter(Session session, Member member) {
wantWriter.remove(member.getIdLong());
getTextChannel().sendMessage(MessageFormat.format(getBundle(session).getString("Leave"), member.getUser().getAsMention())).queue();
getTextChannel().sendMessageFormat(getBundle(session).getString("Leave"), member.getUser().getAsMention()).queue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ public WhatIsItEvents(WhatIsIt whatIsIt){
}
@SubscribeEvent
public void onGuess(MessageReceivedEvent event){
try {
try{
if (event.getChannel().getIdLong() != whatIsIt.getTextChannelId() || event.getMember() == null)
;
return;
var session = Linwood.getInstance().getDatabase().getSessionFactory().openSession();
var message = event.getMessage();
if (whatIsIt.getTextChannelId() == message.getTextChannel().getIdLong()){
var round = whatIsIt.getRound();
if (round != null && round.getWord() != null && message.getContentStripped().toLowerCase().contains(round.getWord().toLowerCase())) {
message.delete().queue();
if (!round.isGuesser(event.getMember()) && message.getAuthor().getIdLong() != round.getWriterId())
event.getChannel().sendMessage(MessageFormat.format(whatIsIt.getBundle(session).getString("Guess"), event.getAuthor().getName(), round.guessCorrectly(event.getMember()))).queue(message1 -> {
event.getChannel().sendMessageFormat(whatIsIt.getBundle(session).getString("Guess"), event.getAuthor().getName(), round.guessCorrectly(event.getMember())).queue(message1 -> {
var session1 = Linwood.getInstance().getDatabase().getSessionFactory().openSession();
round.checkEverybody(session1);
session1.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void run() {
String message = null;
switch (time) {
case 120:
message = MessageFormat.format(bundle.getString("CountdownMinutes"), time / 60);
message = String.format(bundle.getString("CountdownMinutes"), time / 60);
break;
case 60:
message = bundle.getString("CountdownMinute");
Expand All @@ -84,7 +84,7 @@ public void run() {
case 4:
case 3:
case 2:
message = MessageFormat.format(bundle.getString("CountdownSeconds"), time);
message = String.format(bundle.getString("CountdownSeconds"), time);
break;
case 1:
message = bundle.getString("CountdownSecond");
Expand All @@ -101,7 +101,7 @@ public void stopRound(){
var session = Linwood.getInstance().getDatabase().getSessionFactory().openSession();
var bundle = whatIsIt.getBundle(session);
if(word != null)
whatIsIt.getTextChannel().sendMessage(MessageFormat.format(bundle.getString("Word"), word)).queue();
whatIsIt.getTextChannel().sendMessageFormat(bundle.getString("Word"), word).queue();
stopTimer();
session.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public boolean onCommand(Session session, Message message, GuildEntity entity, S
message.getChannel().sendMessage(bundle.getString("Between")).queue();
message.getChannel().getHistory().retrievePast(count).queue(messages -> {
messages.forEach(deleteMessage -> deleteMessage.delete().queue());
message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Success"), messages.size())).queue();
message.getChannel().sendMessageFormat(bundle.getString("Success"), messages.size()).queue();
});
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public boolean onCommand(Session session, Message message, GuildEntity entity, S
if (!command.onCommand(session, message, entity,
(args.length > 0) ? args[0] : "",
(args.length > 0) ? Arrays.copyOfRange(args, 1, args.length) : new String[0]))
message.getChannel().sendMessage(MessageFormat.format(ResourceBundle.getBundle("locale.Command").getString("Syntax"), Objects.requireNonNull(command.getBundle(entity)).getString("Syntax"))).queue();
message.getChannel().sendMessageFormat(ResourceBundle.getBundle("locale.Command").getString("Syntax"), Objects.requireNonNull(command.getBundle(entity)).getString("Syntax")).queue();
}
else
message.getChannel().sendMessage(baseBundle.getString("NoPermission")).queue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public String infoFormat(Message message, GuildEntity entity, String text){
long hour = (uptime / (1000 * 60 * 60)) % 24;
long days = (uptime / (1000 * 60 * 24));
var prefixes = String.join(", ", entity.getPrefixes());
return MessageFormat.format(text, Linwood.getInstance().getVersion(), message.getAuthor().getAsMention(), prefixes.isBlank()? " ": prefixes,
return String.format(text, Linwood.getInstance().getVersion(), message.getAuthor().getAsMention(), prefixes.isBlank()? " ": prefixes,
days, hour, minute, second, millis, Linwood.getInstance().getConfig().getSupportURL());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public boolean onCommand(Session session, Message message, GuildEntity entity, S
var bundle = getBundle(entity);
message.getChannel().sendMessage(new EmbedBuilder()
.addField(bundle.getString("Plan"), bundle.getString("Plan" + entity.getPlan().name()), false)
.addField(bundle.getString("PrefixLimitTitle"), MessageFormat.format(bundle.getString("PrefixLimitBody"), entity.getPlan().getPrefixLimit()), false)
.addField(bundle.getString("PrefixLimitTitle"), String.format(bundle.getString("PrefixLimitBody"), entity.getPlan().getPrefixLimit()), false)
.build()).queue();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public boolean onCommand(Session session, Message message, GuildEntity entity, S
if(args.length > 0)
return false;
var bundle = getBundle(entity);
message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Output"), random.nextInt(5) + 1)).queue();
message.getChannel().sendMessageFormat(bundle.getString("Output"), random.nextInt(5) + 1).queue();
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public boolean onCommand(Session session, Message message, GuildEntity entity, S
description.append(bundle.getString("LeaderboardBodyStart"));
for (int i = 0; i < members.size(); i++) {
var member = members.get(i);
description.append(MessageFormat.format(bundle.getString("LeaderboardBody"), i, member.getUser().getAsMention(), leaderboard[i].getLikes() - leaderboard[i].getDislikes(),
description.append(String.format(bundle.getString("LeaderboardBody"), i, member.getUser().getAsMention(), leaderboard[i].getLikes() - leaderboard[i].getDislikes(),
leaderboard[i].getLikes(), leaderboard[i].getDislikes()));
}
description.append(bundle.getString("LeaderboardBodyEnd"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public boolean onCommand(Session session, Message message, GuildEntity entity, S
return false;
if(args.length == 0)
if(entity.getGameEntity().getGameCategoryId() != null)
message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Get"), entity.getGameEntity().getGameCategory().getName(), entity.getGameEntity().getGameCategoryId())).queue();
message.getChannel().sendMessageFormat(bundle.getString("Get"), entity.getGameEntity().getGameCategory().getName(), entity.getGameEntity().getGameCategoryId()).queue();
else
message.getChannel().sendMessage(bundle.getString("GetNull")).queue();
else {
Expand All @@ -50,7 +50,7 @@ else if(categories.size() > 1)
}
entity.getGameEntity().setGameCategory(category);
entity.save(session);
message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Set"), entity.getGameEntity().getGameCategory().getName(), entity.getGameEntity().getGameCategoryId())).queue();
message.getChannel().sendMessageFormat(bundle.getString("Set"), entity.getGameEntity().getGameCategory().getName(), entity.getGameEntity().getGameCategoryId()).queue();
}catch(NullPointerException e){
message.getChannel().sendMessage(bundle.getString("NotValid")).queue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public boolean onCommand(Session session, Message message, GuildEntity entity, S
if(args.length > 1)
return false;
if(args.length == 0)
message.getChannel().sendMessage((entity.getGameEntity().getGameCategoryId() != null)?MessageFormat.format(bundle.getString("Get"), entity.getGameEntity().getGameMasterRole().getName(), entity.getGameEntity().getGameMasterRoleId()):
bundle.getString("GetNull")).queue();
if((entity.getGameEntity().getGameCategoryId() != null))
message.getChannel().sendMessageFormat(bundle.getString("Get"), entity.getGameEntity().getGameMasterRole().getName(), entity.getGameEntity().getGameMasterRoleId()).queue();
else
message.getChannel().sendMessage(bundle.getString("GetNull")).queue();
else {
try {
Role role = null;
Expand All @@ -48,7 +50,7 @@ else if(roles.size() > 1)
return true;
entity.getGameEntity().setGameMasterRole(role);
entity.save(session);
message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Set"), entity.getGameEntity().getGameMasterRole().getName(), entity.getGameEntity().getGameMasterRoleId())).queue();
message.getChannel().sendMessageFormat(bundle.getString("Set"), entity.getGameEntity().getGameMasterRole().getName(), entity.getGameEntity().getGameMasterRoleId()).queue();
}catch(NullPointerException e){
message.getChannel().sendMessage(bundle.getString("NotValid")).queue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public boolean onCommand(Session session, Message message, GuildEntity entity, S
return true;
}
entity.save(session);
message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Success"), prefix)).queue();
message.getChannel().sendMessageFormat(bundle.getString("Success"), prefix).queue();
} catch (NullPointerException e) {
message.getChannel().sendMessage(bundle.getString("NotValid")).queue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public boolean onCommand(Session session, Message message, GuildEntity entity, S
if(args.length > 1)
return false;
if(args.length == 0)
message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Get"), entity.getLocalization().getDisplayName(entity.getLocalization()))).queue();
message.getChannel().sendMessageFormat(bundle.getString("Get"), entity.getLocalization().getDisplayName(entity.getLocalization())).queue();
else {
try {
entity.setLocale(args[0]);
entity.save(session);
message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Set"), entity.getLocalization().getDisplayName(entity.getLocalization()))).queue();
message.getChannel().sendMessageFormat(bundle.getString("Set"), entity.getLocalization().getDisplayName(entity.getLocalization())).queue();
}catch(NullPointerException e){
message.getChannel().sendMessage(bundle.getString("NotValid")).queue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public boolean onCommand(Session session, Message message, GuildEntity entity, S
return false;
if(args.length == 0)
if(entity.getMaintainerId() != null)
message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Get"), entity.getMaintainer().getName(), entity.getMaintainerId())).queue();
message.getChannel().sendMessageFormat(bundle.getString("Get"), entity.getMaintainer().getName(), entity.getMaintainerId()).queue();
else
message.getChannel().sendMessage(bundle.getString("GetNull")).queue();
else {
Expand All @@ -45,7 +45,7 @@ else if(roles.size() > 1)
return true;
entity.setMaintainer(role);
entity.save(session);
message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Set"), entity.getMaintainer().getName(), entity.getMaintainerId())).queue();
message.getChannel().sendMessageFormat(bundle.getString("Set"), entity.getMaintainer().getName(), entity.getMaintainerId()).queue();
}catch(NullPointerException e){
message.getChannel().sendMessage(bundle.getString("NotValid")).queue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public boolean onCommand(Session session, Message message, GuildEntity entity, S
if(args.length != 0)
return false;
var bundle = getBundle(entity);
message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Get"), String.join("," , entity.getPrefixes()))).queue();
message.getChannel().sendMessageFormat(bundle.getString("Get"), String.join("," , entity.getPrefixes())).queue();
return true;
}

Expand Down
Loading