Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit f032f7f

Browse files
authored
GH-53 Code cleanup, bump dependencies, add run-paper plugin. (#53)
* Add this keywords, .editorconfig and update spigot-api * Update .gitignore and add run-paper gradle plugin
1 parent cf3bb64 commit f032f7f

23 files changed

+149
-120
lines changed

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = crlf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = false
9+
max_line_length = 120
10+
tab_width = 4
11+
ij_continuation_indent_size = 8
12+
ij_formatter_off_tag = @formatter:off
13+
ij_formatter_on_tag = @formatter:on
14+
ij_formatter_tags_enabled = false
15+
ij_smart_tabs = false
16+
ij_visual_guides = none
17+
ij_wrap_on_typing = false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
out/
77
build/
88
/.idea/
9+
run/
910

1011
.DS_Store
1112
[Dd]esktop.ini

bukkit/build.gradle.kts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ plugins {
44
id("com.eternalcode.java-conventions")
55
id("com.github.johnrengelman.shadow") version "7.1.2"
66
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
7+
id("xyz.jpenilla.run-paper") version "2.0.1"
78
}
89

910
dependencies {
1011
implementation(project(":core"))
1112

12-
compileOnly("org.spigotmc:spigot-api:1.19.1-R0.1-SNAPSHOT")
13+
compileOnly("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")
1314
implementation("io.papermc:paperlib:1.0.8")
1415
implementation("dev.rollczi.litecommands:bukkit:2.8.0")
1516

@@ -56,3 +57,9 @@ tasks.withType<ShadowJar> {
5657
relocate(pack, "$prefix.$pack")
5758
}
5859
}
60+
61+
tasks {
62+
runServer {
63+
minecraftVersion("1.19.3")
64+
}
65+
}

core/src/main/java/com/eternalcode/randomtp/EternalRandomTp.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
import com.eternalcode.randomtp.shared.Scheduler;
1212
import com.eternalcode.randomtp.shared.Valid;
1313
import com.eternalcode.randomtp.teleport.TeleportAlgorithm;
14+
import com.eternalcode.randomtp.teleport.TeleportCorrector;
1415
import com.eternalcode.randomtp.teleport.TeleportFilter;
16+
import com.eternalcode.randomtp.teleport.TeleportRange;
17+
import com.eternalcode.randomtp.teleport.TeleportService;
1518
import com.eternalcode.randomtp.teleport.game.TeleportGame;
1619
import com.eternalcode.randomtp.teleport.game.TeleportGameController;
1720
import com.eternalcode.randomtp.teleport.game.TeleportGameRepository;
18-
import com.eternalcode.randomtp.teleport.TeleportCorrector;
19-
import com.eternalcode.randomtp.teleport.TeleportRange;
20-
import com.eternalcode.randomtp.teleport.TeleportService;
2121
import com.eternalcode.randomtp.teleport.game.TeleportType;
2222
import com.eternalcode.randomtp.teleport.game.TeleportTypeRegistry;
2323
import dev.rollczi.litecommands.LiteCommands;
@@ -101,51 +101,51 @@ private EternalRandomTp(
101101
}
102102

103103
public Scheduler getScheduler() {
104-
return scheduler;
104+
return this.scheduler;
105105
}
106106

107107
public Game getGame() {
108-
return game;
108+
return this.game;
109109
}
110110

111111
public TeleportAlgorithm getAlgorithm() {
112-
return algorithm;
112+
return this.algorithm;
113113
}
114114

115115
public TeleportRange getTeleportRange() {
116-
return teleportRange;
116+
return this.teleportRange;
117117
}
118118

119119
public TeleportCorrector getPreCorrector() {
120-
return preCorrector;
120+
return this.preCorrector;
121121
}
122122

123123
public TeleportGameRepository getTeleportRepository() {
124-
return teleportRepository;
124+
return this.teleportRepository;
125125
}
126126

127127
public TeleportTypeRegistry getTypeRegistry() {
128-
return typeRegistry;
128+
return this.typeRegistry;
129129
}
130130

131131
public TeleportService getTeleportService() {
132-
return teleportService;
132+
return this.teleportService;
133133
}
134134

135135
public TeleportGameController getTeleportGameController() {
136-
return teleportGameController;
136+
return this.teleportGameController;
137137
}
138138

139139
public File getDataFolder() {
140-
return dataFolder;
140+
return this.dataFolder;
141141
}
142142

143143
public CdnConfigManager getConfigManager() {
144-
return configManager;
144+
return this.configManager;
145145
}
146146

147147
public LiteCommands<SENDER> getLiteCommands() {
148-
return liteCommands;
148+
return this.liteCommands;
149149
}
150150

151151
public static <SENDER> Builder<SENDER> builder() {
@@ -230,32 +230,32 @@ public Builder<SENDER> profileExtractor(ProfileContextual.Extractor<SENDER> prof
230230
}
231231

232232
public EternalRandomTp<SENDER> build() {
233-
Valid.notNull(game, "Game cannot be null");
234-
Valid.notNull(scheduler, "Scheduler cannot be null");
235-
Valid.notNull(dataFolder, "Data folder cannot be null");
233+
Valid.notNull(this.game, "Game cannot be null");
234+
Valid.notNull(this.scheduler, "Scheduler cannot be null");
235+
Valid.notNull(this.dataFolder, "Data folder cannot be null");
236236

237-
Valid.notNull(algorithm, "Algorithm cannot be null");
238-
Valid.notNull(teleportRange, "Teleport range cannot be null");
239-
Valid.notNull(preCorrector, "Position corrector cannot be null");
237+
Valid.notNull(this.algorithm, "Algorithm cannot be null");
238+
Valid.notNull(this.teleportRange, "Teleport range cannot be null");
239+
Valid.notNull(this.preCorrector, "Position corrector cannot be null");
240240

241-
Valid.notNull(builder, "LiteCommandsBuilder cannot be null");
242-
Valid.notNull(profileExtractor, "Profile extractor cannot be null");
241+
Valid.notNull(this.builder, "LiteCommandsBuilder cannot be null");
242+
Valid.notNull(this.profileExtractor, "Profile extractor cannot be null");
243243

244-
if (cdnConfigManager == null) {
245-
cdnConfigManager = new CdnConfigManager(scheduler, dataFolder);
244+
if (this.cdnConfigManager == null) {
245+
this.cdnConfigManager = new CdnConfigManager(this.scheduler, this.dataFolder);
246246
}
247247

248-
cdnConfigManager.load();
248+
this.cdnConfigManager.load();
249249

250-
if (teleportRepository == null) {
251-
teleportRepository = cdnConfigManager.getTeleportData();
250+
if (this.teleportRepository == null) {
251+
this.teleportRepository = this.cdnConfigManager.getTeleportData();
252252
}
253253

254-
if (typeRegistry == null) {
255-
typeRegistry = cdnConfigManager.getPluginConfig();
254+
if (this.typeRegistry == null) {
255+
this.typeRegistry = this.cdnConfigManager.getPluginConfig();
256256
}
257257

258-
return new EternalRandomTp<>(game, scheduler, dataFolder, cdnConfigManager, algorithm, teleportRange, preCorrector, postCorrector, teleportRepository, typeRegistry , builder, profileExtractor);
258+
return new EternalRandomTp<>(this.game, this.scheduler, this.dataFolder, this.cdnConfigManager, this.algorithm, this.teleportRange, this.preCorrector, this.postCorrector, this.teleportRepository, this.typeRegistry, this.builder, this.profileExtractor);
259259
}
260260

261261
}

core/src/main/java/com/eternalcode/randomtp/command/ProfileContextual.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public ProfileContextual(Extractor<SENDER> extractor) {
1717

1818
@Override
1919
public Result<Profile, ?> extract(SENDER sender, Invocation<SENDER> invocation) {
20-
return extractor.extract(invocation).toResult(Blank.BLANK);
20+
return this.extractor.extract(invocation).toResult(Blank.BLANK);
2121
}
2222

2323
public interface Extractor<SENDER> {

core/src/main/java/com/eternalcode/randomtp/command/RandomTpCommand.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.eternalcode.randomtp.command;
22

33
import com.eternalcode.randomtp.config.CdnPluginConfig;
4-
import com.eternalcode.randomtp.shared.Placeholders;
54
import com.eternalcode.randomtp.profile.Profile;
65
import com.eternalcode.randomtp.shared.BlockType;
76
import com.eternalcode.randomtp.shared.Game;
7+
import com.eternalcode.randomtp.shared.Placeholders;
88
import com.eternalcode.randomtp.shared.Position;
99
import com.eternalcode.randomtp.teleport.TeleportService;
1010
import com.eternalcode.randomtp.teleport.game.TeleportGame;
@@ -39,7 +39,7 @@ public RandomTpCommand(Game game, TeleportGameRepository repository, TeleportSer
3939

4040
@Execute
4141
public void execute(LiteSender sender, Profile profile) {
42-
this.teleportService.teleportProfile(profile, profile.getUniverse(), result -> sender.sendMessage(result.isSuccess() ? pluginConfig.onTeleport : pluginConfig.onTeleportFail));
42+
this.teleportService.teleportProfile(profile, profile.getUniverse(), result -> sender.sendMessage(result.isSuccess() ? this.pluginConfig.onTeleport : this.pluginConfig.onTeleportFail));
4343
}
4444

4545
@Execute(route = "create", required = 2)
@@ -55,7 +55,7 @@ public void set(
5555
Optional<Position> optionalPosition = profile.getTargetPosition();
5656

5757
if (optionalPosition.isEmpty()) {
58-
sender.sendMessage(pluginConfig.onNoPosition);
58+
sender.sendMessage(this.pluginConfig.onNoPosition);
5959
return;
6060
}
6161

@@ -64,7 +64,7 @@ public void set(
6464
Option<TeleportGame> teleport = this.repository.getTeleport(name);
6565

6666
if (teleport.isPresent()) {
67-
sender.sendMessage(pluginConfig.onTeleportExists);
67+
sender.sendMessage(this.pluginConfig.onTeleportExists);
6868
return;
6969
}
7070

@@ -81,21 +81,21 @@ public void set(
8181
this.setButton(target, buttonType, 0, 1);
8282
// TODO: Move to other class {END}
8383

84-
sender.sendMessage(pluginConfig.onCreate);
84+
sender.sendMessage(this.pluginConfig.onCreate);
8585
}
8686

8787
@Execute(route = "delete", required = 1)
8888
@Permission("eternalcode.command.randomtp.delete")
8989
public void delete(LiteSender sender, @Arg TeleportGame teleport) {
9090
this.repository.deleteTeleport(teleport.getName());
91-
sender.sendMessage(pluginConfig.onDelete);
91+
sender.sendMessage(this.pluginConfig.onDelete);
9292
}
9393

9494
@Execute(route = "list")
9595
@Permission("eternalcode.command.randomtp.list")
9696
public void list(LiteSender sender) {
9797
for (TeleportGame teleport : this.repository.getTeleports()) {
98-
String message = Placeholders.format(pluginConfig.teleportInfo, teleport);
98+
String message = Placeholders.format(this.pluginConfig.teleportInfo, teleport);
9999

100100
sender.sendMessage(message);
101101
}

core/src/main/java/com/eternalcode/randomtp/command/TeleportGameArg.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public TeleportGameArg(TeleportGameRepository repository, CdnPluginConfig plugin
2525
@Override
2626
public Result<TeleportGame, ?> parse(LiteInvocation invocation, String argument) {
2727
return this.repository.getTeleport(argument)
28-
.toResult(pluginConfig.teleportTypeNotExist);
28+
.toResult(this.pluginConfig.teleportTypeNotExist);
2929
}
3030

3131
@Override
3232
public List<Suggestion> suggest(LiteInvocation invocation) {
33-
return repository.getTeleports().stream()
33+
return this.repository.getTeleports().stream()
3434
.map(TeleportGame::getName)
3535
.map(Suggestion::of)
3636
.toList();

core/src/main/java/com/eternalcode/randomtp/command/TeleportTypeArg.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public TeleportTypeArg(TeleportTypeRegistry registry, CdnPluginConfig pluginConf
2525
@Override
2626
public Result<TeleportType, ?> parse(LiteInvocation invocation, String argument) {
2727
return this.registry.getType(argument)
28-
.toResult(pluginConfig.teleportTypeNotExist);
28+
.toResult(this.pluginConfig.teleportTypeNotExist);
2929
}
3030

3131
@Override
3232
public List<Suggestion> suggest(LiteInvocation invocation) {
33-
return registry.getTypes().keySet().stream()
33+
return this.registry.getTypes().keySet().stream()
3434
.map(Suggestion::of)
3535
.toList();
3636
}

core/src/main/java/com/eternalcode/randomtp/config/CdnConfigManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public void renderAsync() {
4545
}
4646

4747
public CdnPluginConfig getPluginConfig() {
48-
return pluginConfig;
48+
return this.pluginConfig;
4949
}
5050

5151
public CdnTeleportGameRepository getTeleportData() {
52-
return teleportData;
52+
return this.teleportData;
5353
}
5454

5555
private void loadAndRender(String name, Object object) {

core/src/main/java/com/eternalcode/randomtp/shared/BlockState.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public BlockState(Position position, BlockType blockType) {
1313
}
1414

1515
public BlockType getBlockType() {
16-
return blockType;
16+
return this.blockType;
1717
}
1818

1919
public Position getPosition() {
20-
return position;
20+
return this.position;
2121
}
2222

2323
@Override
@@ -30,11 +30,11 @@ public boolean equals(Object obj) {
3030
return false;
3131
}
3232

33-
return position.equals(that.position) && blockType.equals(that.blockType);
33+
return this.position.equals(that.position) && this.blockType.equals(that.blockType);
3434
}
3535

3636
@Override
3737
public int hashCode() {
38-
return Objects.hash(position, blockType);
38+
return Objects.hash(this.position, this.blockType);
3939
}
4040
}

0 commit comments

Comments
 (0)