Skip to content

Commit 3a51a4d

Browse files
committed
Improved code quailtiy
1 parent b29dc61 commit 3a51a4d

File tree

3 files changed

+48
-49
lines changed

3 files changed

+48
-49
lines changed

src/main/java/de/lars/utilsmanager/features/court/CourtManager.java

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void checkCriminal() {
8383
onlineplayer.sendMessage(Statements.getPrefix()
8484
.append(Component.text("Die Gerichtsversammlung beginnt in 60 Sekunden. Kommst du?", NamedTextColor.WHITE)));
8585

86-
ComponentBuilder comeChecker = Component.text("").append(Statements.getPrefix()).toBuilder();
86+
ComponentBuilder<TextComponent, TextComponent.Builder> comeChecker = Component.text("").append(Statements.getPrefix()).toBuilder();
8787
Component comeMessageYes = Component.text("[Ja]")
8888
.color(NamedTextColor.GREEN)
8989
.clickEvent(ClickEvent.runCommand("/court join"))
@@ -115,7 +115,7 @@ public void checkCriminal() {
115115
onlineplayer.sendMessage(Statements.getPrefix()
116116
.append(Component.text("The court meeting begins in 60 seconds. Do you come?", NamedTextColor.WHITE)));
117117

118-
ComponentBuilder comeChecker = Component.text("").append(Statements.getPrefix()).toBuilder();
118+
ComponentBuilder<TextComponent, TextComponent.Builder> comeChecker = Component.text("").append(Statements.getPrefix()).toBuilder();
119119
Component comeMessageYes = Component.text("[Yes]")
120120
.color(NamedTextColor.GREEN)
121121
.clickEvent(ClickEvent.runCommand("/court join"))
@@ -161,12 +161,12 @@ public void checkCriminal() {
161161
return;
162162
}
163163
World world = Bukkit.getWorld("world");
164-
Location placecriminal = new Location(world, -74, 132, 173);
165-
placecriminal.setYaw(-180);
166-
placecriminal.setPitch(0);
167-
player.teleport(placecriminal);
164+
Location placeCriminal = new Location(world, -74, 132, 173);
165+
placeCriminal.setYaw(-180);
166+
placeCriminal.setPitch(0);
167+
player.teleport(placeCriminal);
168168

169-
ArmorStand armorStandCriminal = (ArmorStand) placecriminal.getWorld().spawnEntity(placecriminal.add(0.5, -1.40, 0.5), EntityType.ARMOR_STAND);
169+
ArmorStand armorStandCriminal = (ArmorStand) placeCriminal.getWorld().spawnEntity(placeCriminal.add(0.5, -1.40, 0.5), EntityType.ARMOR_STAND);
170170
armorStandCriminal.setVisible(false);
171171
armorStandCriminal.setGravity(false);
172172
armorStandCriminal.addPassenger(player);
@@ -176,6 +176,7 @@ public void checkCriminal() {
176176
Location placeProsecutor = new Location(world, -75, 132, 173);
177177
placeProsecutor.setYaw(-180);
178178
placeProsecutor.setPitch(0);
179+
assert prosecutor != null;
179180
prosecutor.teleport(placeProsecutor);
180181

181182
ArmorStand armorStandProsecutor = (ArmorStand) placeProsecutor.getWorld().spawnEntity(placeProsecutor.add(0.5, -1.40, 0.5), EntityType.ARMOR_STAND);
@@ -559,7 +560,7 @@ public void checkCriminal() {
559560
if (LanguageAPI.getApi().getLanguage(member) == 2) {
560561
member.sendMessage(Statements.getPrefix().append(Component.text("Die Verhandlung hat begonnen!", NamedTextColor.LIGHT_PURPLE)));
561562

562-
ComponentBuilder wittnesChecker = Component.text("").append(Statements.getPrefix())
563+
ComponentBuilder<TextComponent, TextComponent.Builder> wittnesChecker = Component.text("").append(Statements.getPrefix())
563564
.append(Component.text("Hast du etwas zu bezeugen? : ", NamedTextColor.GRAY)).toBuilder();
564565
Component witnessYes = Component.text("[Ja]")
565566
.color(NamedTextColor.GREEN)
@@ -569,14 +570,14 @@ public void checkCriminal() {
569570
member.sendMessage(wittnesChecker.build());
570571
} else {
571572
member.sendMessage(Statements.getPrefix().append(Component.text("The negotiation has started!", NamedTextColor.LIGHT_PURPLE)));
572-
ComponentBuilder wittnesChecker = Component.text("").append(Statements.getPrefix())
573+
ComponentBuilder<TextComponent, TextComponent.Builder> witnessChecker = Component.text("").append(Statements.getPrefix())
573574
.append(Component.text("Do you have something to testify? : ", NamedTextColor.GRAY)).toBuilder();
574575
Component witnessYes = Component.text("[Yes]")
575576
.color(NamedTextColor.GREEN)
576577
.clickEvent(ClickEvent.runCommand("/court witness"))
577578
.hoverEvent(HoverEvent.showText(Component.text("You will get a witnesser").color(NamedTextColor.GREEN)));
578-
wittnesChecker.append(witnessYes);
579-
member.sendMessage(wittnesChecker.build());
579+
witnessChecker.append(witnessYes);
580+
member.sendMessage(witnessChecker.build());
580581
}
581582
TimerAPI.getApi().setEnabled(member, true);
582583
TimerAPI.getApi().setTimer(member, true);
@@ -756,7 +757,7 @@ public void checkCriminal() {
756757
.append(Component.text("|----------------------------------|", NamedTextColor.DARK_GRAY)));
757758
}
758759
}
759-
Integer cell = new Random().nextInt(5) + 1;
760+
int cell = new Random().nextInt(5) + 1;
760761
TimerAPI.getApi().setEnabled(player, true);
761762
TimerAPI.getApi().setTime(player, 600);
762763
TimerAPI.getApi().setTimer(player, true);
@@ -958,7 +959,7 @@ public void sitOn() {
958959
armorStand.setVisible(false);
959960
armorStand.setGravity(false);
960961

961-
armorStand.addPassenger(member);
962+
armorStand.addPassenger(player);
962963
break;
963964
}
964965

@@ -972,7 +973,7 @@ public void sitOn() {
972973
armorStand.setVisible(false);
973974
armorStand.setGravity(false);
974975

975-
armorStand.addPassenger(member);
976+
armorStand.addPassenger(player);
976977
break;
977978
}
978979

@@ -986,7 +987,7 @@ public void sitOn() {
986987
armorStand.setVisible(false);
987988
armorStand.setGravity(false);
988989

989-
armorStand.addPassenger(member);
990+
armorStand.addPassenger(player);
990991
break;
991992
}
992993

@@ -1000,7 +1001,7 @@ public void sitOn() {
10001001
armorStand.setVisible(false);
10011002
armorStand.setGravity(false);
10021003

1003-
armorStand.addPassenger(member);
1004+
armorStand.addPassenger(player);
10041005
break;
10051006
}
10061007

@@ -1014,7 +1015,7 @@ public void sitOn() {
10141015
armorStand.setVisible(false);
10151016
armorStand.setGravity(false);
10161017

1017-
armorStand.addPassenger(member);
1018+
armorStand.addPassenger(player);
10181019
break;
10191020
}
10201021

@@ -1028,7 +1029,7 @@ public void sitOn() {
10281029
armorStand.setVisible(false);
10291030
armorStand.setGravity(false);
10301031

1031-
armorStand.addPassenger(member);
1032+
armorStand.addPassenger(player);
10321033
break;
10331034
}
10341035

@@ -1042,7 +1043,7 @@ public void sitOn() {
10421043
armorStand.setVisible(false);
10431044
armorStand.setGravity(false);
10441045

1045-
armorStand.addPassenger(member);
1046+
armorStand.addPassenger(player);
10461047
break;
10471048
}
10481049

@@ -1056,7 +1057,7 @@ public void sitOn() {
10561057
armorStand.setVisible(false);
10571058
armorStand.setGravity(false);
10581059

1059-
armorStand.addPassenger(member);
1060+
armorStand.addPassenger(player);
10601061
break;
10611062
}
10621063

@@ -1070,7 +1071,7 @@ public void sitOn() {
10701071
armorStand.setVisible(false);
10711072
armorStand.setGravity(false);
10721073

1073-
armorStand.addPassenger(member);
1074+
armorStand.addPassenger(player);
10741075
break;
10751076
}
10761077

@@ -1084,7 +1085,7 @@ public void sitOn() {
10841085
armorStand.setVisible(false);
10851086
armorStand.setGravity(false);
10861087

1087-
armorStand.addPassenger(member);
1088+
armorStand.addPassenger(player);
10881089
break;
10891090
}
10901091

@@ -1098,7 +1099,7 @@ public void sitOn() {
10981099
armorStand.setVisible(false);
10991100
armorStand.setGravity(false);
11001101

1101-
armorStand.addPassenger(member);
1102+
armorStand.addPassenger(player);
11021103
break;
11031104
}
11041105

@@ -1112,7 +1113,7 @@ public void sitOn() {
11121113
armorStand.setVisible(false);
11131114
armorStand.setGravity(false);
11141115

1115-
armorStand.addPassenger(member);
1116+
armorStand.addPassenger(player);
11161117
break;
11171118
}
11181119

@@ -1126,7 +1127,7 @@ public void sitOn() {
11261127
armorStand.setVisible(false);
11271128
armorStand.setGravity(false);
11281129

1129-
armorStand.addPassenger(member);
1130+
armorStand.addPassenger(player);
11301131
break;
11311132
}
11321133

@@ -1140,7 +1141,7 @@ public void sitOn() {
11401141
armorStand.setVisible(false);
11411142
armorStand.setGravity(false);
11421143

1143-
armorStand.addPassenger(member);
1144+
armorStand.addPassenger(player);
11441145
break;
11451146
}
11461147

@@ -1154,7 +1155,7 @@ public void sitOn() {
11541155
armorStand.setVisible(false);
11551156
armorStand.setGravity(false);
11561157

1157-
armorStand.addPassenger(member);
1158+
armorStand.addPassenger(player);
11581159
break;
11591160
}
11601161

@@ -1168,7 +1169,7 @@ public void sitOn() {
11681169
armorStand.setVisible(false);
11691170
armorStand.setGravity(false);
11701171

1171-
armorStand.addPassenger(member);
1172+
armorStand.addPassenger(player);
11721173
break;
11731174
}
11741175

@@ -1182,7 +1183,7 @@ public void sitOn() {
11821183
armorStand.setVisible(false);
11831184
armorStand.setGravity(false);
11841185

1185-
armorStand.addPassenger(member);
1186+
armorStand.addPassenger(player);
11861187
break;
11871188
}
11881189

@@ -1196,7 +1197,7 @@ public void sitOn() {
11961197
armorStand.setVisible(false);
11971198
armorStand.setGravity(false);
11981199

1199-
armorStand.addPassenger(member);
1200+
armorStand.addPassenger(player);
12001201
break;
12011202
}
12021203

@@ -1210,7 +1211,7 @@ public void sitOn() {
12101211
armorStand.setVisible(false);
12111212
armorStand.setGravity(false);
12121213

1213-
armorStand.addPassenger(member);
1214+
armorStand.addPassenger(player);
12141215
break;
12151216
}
12161217

@@ -1224,7 +1225,7 @@ public void sitOn() {
12241225
armorStand.setVisible(false);
12251226
armorStand.setGravity(false);
12261227

1227-
armorStand.addPassenger(member);
1228+
armorStand.addPassenger(player);
12281229
break;
12291230
}
12301231

@@ -1238,7 +1239,7 @@ public void sitOn() {
12381239
armorStand.setVisible(false);
12391240
armorStand.setGravity(false);
12401241

1241-
armorStand.addPassenger(member);
1242+
armorStand.addPassenger(player);
12421243
break;
12431244
}
12441245

@@ -1252,7 +1253,7 @@ public void sitOn() {
12521253
armorStand.setVisible(false);
12531254
armorStand.setGravity(false);
12541255

1255-
armorStand.addPassenger(member);
1256+
armorStand.addPassenger(player);
12561257
break;
12571258
}
12581259

@@ -1266,7 +1267,7 @@ public void sitOn() {
12661267
armorStand.setVisible(false);
12671268
armorStand.setGravity(false);
12681269

1269-
armorStand.addPassenger(member);
1270+
armorStand.addPassenger(player);
12701271
break;
12711272
}
12721273

@@ -1280,7 +1281,7 @@ public void sitOn() {
12801281
armorStand.setVisible(false);
12811282
armorStand.setGravity(false);
12821283

1283-
armorStand.addPassenger(member);
1284+
armorStand.addPassenger(player);
12841285
break;
12851286
}
12861287

src/main/java/de/lars/utilsmanager/features/timer/TimerCommand.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020

2121
public class TimerCommand implements BasicCommand {
2222

23-
private Player player;
2423
@Override
25-
public void execute(@NotNull CommandSourceStack stack, @NotNull String[] args) {
26-
player = (Player) stack.getSender();
24+
public void execute(@NotNull CommandSourceStack stack, @NotNull String @NotNull [] args) {
25+
Player player = (Player) stack.getSender();
2726

2827
if (!player.hasPermission("plugin.timer")) {
2928
player.sendMessage(Statements.getNotAllowed(player));
@@ -482,7 +481,7 @@ public void execute(@NotNull CommandSourceStack stack, @NotNull String[] args) {
482481
}
483482

484483
@Override
485-
public Collection<String> suggest(final CommandSourceStack commandSourceStack, final String[] args) {
484+
public @NotNull Collection<String> suggest(final @NotNull CommandSourceStack commandSourceStack, final String[] args) {
486485
if (args.length == 0 || args.length == 1) {
487486
Collection<String> timerCommands = new ArrayList<>();
488487
timerCommands.add("resume");

src/main/java/de/lars/utilsmanager/listener/server/ServerPingListener.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,11 @@ public void onServerPing(PaperServerListPingEvent event) {
4949
.append(Component.text(" M", NamedTextColor.GOLD, TextDecoration.OBFUSCATED))
5050
.append(Component.text("\n "));
5151

52-
int infoWidth = totalWidth;
5352
int extraShift = 5;
5453

5554
if (Bukkit.hasWhitelist()) {
5655
String info = "Info: Whitelist enabled!";
57-
Component centered = centerLines(wrapText(info, infoWidth), infoWidth, NamedTextColor.GOLD, extraShift);
56+
Component centered = centerLines(wrapText(info, totalWidth), totalWidth, NamedTextColor.GOLD, extraShift);
5857
event.motd(header.append(centered));
5958
return;
6059
}
@@ -64,24 +63,24 @@ public void onServerPing(PaperServerListPingEvent event) {
6463
lines.add("Info: Server is in maintenance!");
6564
String maintenanceReason = ServerSettingsAPI.getApi().getMaintenanceReason() == null ? "" : ServerSettingsAPI.getApi().getMaintenanceReason().trim();
6665
if (!maintenanceReason.isEmpty()) {
67-
lines.addAll(wrapText(maintenanceReason, infoWidth));
66+
lines.addAll(wrapText(maintenanceReason, totalWidth));
6867
}
69-
Component firstLine = centerLines(List.of(lines.get(0)), infoWidth, NamedTextColor.GREEN, extraShift);
68+
Component firstLine = centerLines(List.of(lines.getFirst()), totalWidth, NamedTextColor.GREEN, extraShift);
7069
List<String> detailLines = lines.size() > 1 ? lines.subList(1, lines.size()) : List.of();
71-
Component details = centerLines(detailLines, infoWidth, NamedTextColor.RED, extraShift);
70+
Component details = centerLines(detailLines, totalWidth, NamedTextColor.RED, extraShift);
7271
event.motd(header.append(firstLine).append(details));
7372
return;
7473
}
7574

7675
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers()) {
7776
String info = "Info: Server is full!";
78-
Component centered = centerLines(wrapText(info, infoWidth), infoWidth, NamedTextColor.RED, extraShift);
77+
Component centered = centerLines(wrapText(info, totalWidth), totalWidth, NamedTextColor.RED, extraShift);
7978
event.motd(header.append(centered));
8079
return;
8180
}
8281

8382
String info = "Info: Server is online!";
84-
Component centered = centerLines(wrapText(info, infoWidth), infoWidth, NamedTextColor.GREEN, extraShift);
83+
Component centered = centerLines(wrapText(info, totalWidth), totalWidth, NamedTextColor.GREEN, extraShift);
8584
event.motd(header.append(centered));
8685
}
8786

@@ -95,7 +94,7 @@ private static List<String> wrapText(String text, int width) {
9594
StringBuilder current = new StringBuilder();
9695

9796
for (String w : words) {
98-
if (current.length() == 0) {
97+
if (current.isEmpty()) {
9998
current.append(w);
10099
} else if (current.length() + 1 + w.length() <= width) {
101100
current.append(' ').append(w);
@@ -104,7 +103,7 @@ private static List<String> wrapText(String text, int width) {
104103
current = new StringBuilder(w);
105104
}
106105
}
107-
if (current.length() > 0) lines.add(current.toString());
106+
if (!current.isEmpty()) lines.add(current.toString());
108107
return lines;
109108
}
110109

0 commit comments

Comments
 (0)