Skip to content

Commit cd1888a

Browse files
committed
Removed some of unused code from ConfigurationUtil, and some minor changes
1 parent 5a54fc3 commit cd1888a

File tree

5 files changed

+20
-55
lines changed

5 files changed

+20
-55
lines changed

src/dev/_2lstudios/viarewindpotions/adapters/WorldEventAdapter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ public void onPacketSending(PacketEvent event) {
3838
final PacketContainer edited = packet.deepClone();
3939
final StructureModifier<Integer> editedIntegers = edited.getIntegers();
4040

41-
if (version <= 210)
41+
if (version <= 210) {
4242
editedIntegers.write(0, 2002);
43+
}
4344

4445
for (final SplashTranslator translator : SplashTranslator.values()) {
4546
if (editedIntegers.read(1) == translator.getRGB()) {
4647
for (final TranslationData data : translator.getDatas()) {
47-
if (data.getLowestVersion() <= version && data.getHighestVersion() >= version)
48+
if (data.getLowestVersion() <= version && data.getHighestVersion() >= version) {
4849
editedIntegers.write(1, data.getRemap());
50+
}
4951
}
5052
}
5153
}

src/dev/_2lstudios/viarewindpotions/listeners/AreaEffectCloudListener.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public AreaEffectCloudListener(final Plugin plugin, final VersionUtil versionUti
2121

2222
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
2323
for (final AreaEffectCloud cloud : effectClouds) {
24-
if (cloud == null || cloud.isDead() || !cloud.isValid())
24+
if (cloud == null || cloud.isDead() || !cloud.isValid()) {
2525
effectClouds.remove(cloud);
26+
}
2627
else {
2728
final Location location = cloud.getLocation();
2829
final float radius = cloud.getRadius();
@@ -39,9 +40,11 @@ public AreaEffectCloudListener(final Plugin plugin, final VersionUtil versionUti
3940
float f3 = (float) Math.cos(f1) * f2;
4041
float f4 = (float) Math.sin(f1) * f2;
4142

42-
for (final Player player : cloud.getWorld().getPlayers())
43-
if (versionUtil.getVersion(player) <= 106)
43+
for (final Player player : cloud.getWorld().getPlayers()) {
44+
if (versionUtil.getVersion(player) <= 106) {
4445
player.spawnParticle(cloud.getParticle(), location.getX() + f3, location.getY(), location.getZ() + f4, 0, red / 255f, green / 255f, blue / 255f);
46+
}
47+
}
4548
}
4649
}
4750
}

src/dev/_2lstudios/viarewindpotions/listeners/SpawnEntityListener.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ public void onPacketSending(final PacketEvent event) {
3939
for (final PotionEffect effect : potion.getEffects()) {
4040
for (final PotionTranslator translator : PotionTranslator.values()) {
4141
if (effect.getType().equals(translator.getPotionEffectType())) {
42-
for (TranslationData data : translator.getDatas())
43-
if (data.getLowestVersion() <= version && data.getHighestVersion() >= version)
42+
for (TranslationData data : translator.getDatas()) {
43+
if (data.getLowestVersion() <= version && data.getHighestVersion() >= version) {
4444
edited.getIntegers().write(7, data.getRemap());
45+
}
46+
}
4547
}
4648
}
4749
}

src/dev/_2lstudios/viarewindpotions/utils/ConfigurationUtil.java

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import org.bukkit.plugin.Plugin;
55

66
import java.io.File;
7-
import java.io.IOException;
87
import java.io.InputStream;
98
import java.nio.file.Files;
109

@@ -19,53 +18,10 @@ public YamlConfiguration getConfiguration(String filePath) {
1918
final File dataFolder = plugin.getDataFolder();
2019
final File file = new File(filePath.replace("%datafolder%", dataFolder.toPath().toString()));
2120

22-
if (file.exists())
21+
if (file.exists()) {
2322
return YamlConfiguration.loadConfiguration(file);
24-
else return new YamlConfiguration();
25-
}
26-
27-
public void createConfiguration(String file) {
28-
try {
29-
final File dataFolder = plugin.getDataFolder();
30-
31-
file = file.replace("%datafolder%", dataFolder.toPath().toString());
32-
33-
final File configFile = new File(file);
34-
35-
if (!configFile.exists()) {
36-
final String[] files = file.split("/");
37-
final InputStream inputStream = plugin.getClass().getClassLoader().getResourceAsStream(files[files.length - 1]);
38-
final File parentFile = configFile.getParentFile();
39-
40-
if (parentFile != null) parentFile.mkdirs();
41-
42-
if (inputStream != null) {
43-
Files.copy(inputStream, configFile.toPath());
44-
System.out.print(("[%pluginname%] File " + configFile + " has been created!").replace("%pluginname%", plugin.getDescription().getName()));
45-
} else configFile.createNewFile();
46-
}
47-
} catch (final IOException e) {
48-
System.out.print(("[%pluginname%] Unable to create configuration file!").replace("%pluginname%", plugin.getDescription().getName()));
4923
}
24+
else return new YamlConfiguration();
5025
}
5126

52-
public void saveConfiguration(final YamlConfiguration yamlConfiguration, final String file) {
53-
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
54-
try {
55-
final File dataFolder = plugin.getDataFolder();
56-
57-
yamlConfiguration.save(file.replace("%datafolder%", dataFolder.toPath().toString()));
58-
} catch (final IOException e) {
59-
System.out.print(("[%pluginname%] Unable to save configuration file!").replace("%pluginname%", plugin.getDescription().getName()));
60-
}
61-
});
62-
}
63-
64-
public void deleteConfiguration(final String file) {
65-
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
66-
final File file1 = new File(file);
67-
68-
if (file1.exists()) file1.delete();
69-
});
70-
}
7127
}

src/dev/_2lstudios/viarewindpotions/utils/VersionUtil.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ public int getVersion(Player player) {
2626
if (protocolSupportVersion == latest && viaVersion != null) {
2727
final int viaVersionVersion = getViaVersionVersion(player);
2828

29-
if (viaVersionVersion != latest)
29+
if (viaVersionVersion != latest) {
3030
return viaVersionVersion;
31+
}
3132
}
3233

3334
return protocolSupportVersion;
34-
} else if (viaVersion != null)
35+
} else if (viaVersion != null) {
3536
return getViaVersionVersion(player);
37+
}
3638

3739
return -1;
3840
}

0 commit comments

Comments
 (0)