Skip to content

Commit

Permalink
使いやすくした & 一部軽量化
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed May 3, 2021
1 parent 99e2d56 commit ccae6a6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
20 changes: 20 additions & 0 deletions 7miTCT/src/main/java/me/clockclap/tct/api/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,24 @@ public Player getNearestPlayer(Player player) {
return result;
}

public PlayerData getPlayerData(String coloredName) {
String name = resetColor(coloredName);
return NanamiTct.plugin.getGame().getReference().PLAYERDATA.get(name);
}

public Collection<? extends PlayerData> getOnlinePlayersData() {
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
Collection<PlayerData> datas = new ArrayList<>();
for(Player p : players) {
if(p != null) {
String name = resetColor(p.getName());
PlayerData data = getPlayerData(name);
if (data != null) {
datas.add(data);
}
}
}
return datas;
}

}
7 changes: 4 additions & 3 deletions 7miTCT/src/main/java/me/clockclap/tct/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private void giveRole(int playersCount) {
int resultCount = villagersMin + healersMin + detectivesMin + wolvesMin + fanaticsMin + foxesMin + immoralMin;
if(playersCount >= resultCount) {
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
for(Player p : Bukkit.getOnlinePlayers()) {
for(Player p : players) {
if (getReference().PLAYERDATA.get(NanamiTct.utilities.resetColor(p.getName())).getRole() != GameRoles.VILLAGER) {
players.remove(p);
}
Expand Down Expand Up @@ -463,7 +463,7 @@ private void giveRole(int playersCount) {
}
getRoleCount().getCustomRoleCount().initialize();
customRoles.clear();
for (Player p : Bukkit.getOnlinePlayers()) {
for (Player p : players) {
if (p != null) {
PlayerData data = getReference().PLAYERDATA.get(NanamiTct.utilities.resetColor(p.getName()));
if (data != null) {
Expand Down Expand Up @@ -497,7 +497,8 @@ private void giveRole(int playersCount) {
}

public void giveItem() {
for(Player p : Bukkit.getOnlinePlayers()) {
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
for(Player p : players) {
PlayerData data = getReference().PLAYERDATA.get(NanamiTct.utilities.resetColor(p.getName()));
if(!data.isSpectator()) {
p.getInventory().setItem(4, getLog().getItem());
Expand Down
11 changes: 10 additions & 1 deletion 7miTCT/src/main/java/me/clockclap/tct/japanize/Japanizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bukkit.entity.Player;

import java.io.UnsupportedEncodingException;
import java.util.Collection;

public class Japanizer {

Expand Down Expand Up @@ -101,10 +102,18 @@ public static String japanize(String input) throws UnsupportedEncodingException
}
result = KanaConverter.conv(msg);
if(ime) {
result = result.replaceAll("むらびと", "村人");
result = result.replaceAll("いしゃ", "医者");
result = result.replaceAll("たんてい", "探偵");
result = result.replaceAll("じんろう", "人狼");
result = result.replaceAll("きょうじん", "狂人");
result = result.replaceAll("ようこ", "妖狐");
result = result.replaceAll("はいとくしゃ", "背徳者");
result = GoogleIME.convByGoogleIME(result);
}
if(jpn) {
for (Player p : Bukkit.getOnlinePlayers()) {
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
for (Player p : players) {
String name = NanamiTct.utilities.resetColor(p.getName());
String japanizedName = KanaConverter.conv(name);
if(ime) japanizedName = GoogleIME.convByGoogleIME(japanizedName);
Expand Down
18 changes: 0 additions & 18 deletions 7miTCT/src/main/java/me/clockclap/tct/japanize/KanaConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,6 @@ protected KanaConverter() {
static {
ImmutableSortedMap.Builder<String, String> builder = ImmutableSortedMap.reverseOrder();

// 単語
builder.put("kyoujin", "狂人");
builder.put("kyoujinn", "狂人");
builder.put("kyouzin", "狂人");
builder.put("kyouzinn", "狂人");
builder.put("youko", "妖狐");
builder.put("jinrou", "人狼");
builder.put("jinnrou", "人狼");
builder.put("zinrou", "人狼");
builder.put("zinnrou", "人狼");
builder.put("tantei", "探偵");
builder.put("tanntei", "探偵");
builder.put("murabito", "村人");
builder.put("kuro", "黒");
builder.put("siro", "白");
builder.put("isya", "医者");
builder.put("isha", "医者");

// ひらがな
builder.put("a", "あ");
builder.put("i", "い").put("yi", "い");
Expand Down

0 comments on commit ccae6a6

Please sign in to comment.