Skip to content

Commit

Permalink
made protocollib softdependent, automatically changes mode when proto…
Browse files Browse the repository at this point in the history
…collib not found.
  • Loading branch information
InstantlyMoist committed Mar 11, 2020
1 parent e4dfbbc commit ca038f6
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 67 deletions.
9 changes: 9 additions & 0 deletions .idea/discord.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/libraries/Maven__junit_junit_4_10.xml

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--bStats API-->
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/me/kyllian/xRay/XRayPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import me.kyllian.xRay.handlers.XRayHandler;
import me.kyllian.xRay.listeners.PlayerMoveListener;
import me.kyllian.xRay.listeners.PlayerQuitListener;
import me.kyllian.xRay.tasks.TaskType;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Material;
Expand All @@ -26,9 +27,12 @@ public class XRayPlugin extends JavaPlugin {

@Override
public void onEnable() {
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") == null) {
Bukkit.getLogger().warning("xRay has been disabled, please download Protocollib!");
Bukkit.getPluginManager().disablePlugin(this);
initializeConfig();
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") == null &&
TaskType.valueOf(getConfig().getString("Settings.Mode")) == TaskType.CHUNK) {
Bukkit.getLogger().warning("ProtocolLib not found, changing mode to BLOCK");
getConfig().set("Settings.Mode", "BLOCK");
saveConfig();
return;
}

Expand All @@ -38,7 +42,7 @@ public void onEnable() {

initializeHandlers();
initializeListeners();
initializeConfig();

}

@Override
Expand All @@ -65,7 +69,8 @@ public void initializeConfig() {

Map<String, WrappedBlockData> tempData = new HashMap<>();
for (String block : getConfig().getStringList("Settings.xRayBlocks")) {
if (Bukkit.getVersion().contains("1.8") || Bukkit.getVersion().contains("1.7")) tempData.put(block, WrappedBlockData.createData(Material.valueOf(block), 1));
if (Bukkit.getVersion().contains("1.8") || Bukkit.getVersion().contains("1.7"))
tempData.put(block, WrappedBlockData.createData(Material.valueOf(block), 1));
else tempData.put(block, WrappedBlockData.createData(Material.valueOf(block)));
}
data = Collections.unmodifiableMap(tempData);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/me/kyllian/xRay/threads/ChunkThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public ChunkThread(XRayPlugin plugin, Chunk chunk, Player player) {
this.plugin = plugin;
this.chunk = chunk;
this.player = player;
barrierBlock = WrappedBlockData.createData(Material.BARRIER);
airBlock = WrappedBlockData.createData(Material.AIR);
boolean old = Bukkit.getVersion().contains("1.8") || Bukkit.getVersion().contains("1.7");
barrierBlock = old ? WrappedBlockData.createData(Material.BARRIER, 1) : WrappedBlockData.createData(Material.BARRIER);
airBlock = old ? WrappedBlockData.createData(Material.AIR, 1) : WrappedBlockData.createData(Material.AIR);
}

public void startTask() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: xRay
version: 3.11
version: 3.12
main: me.kyllian.xRay.XRayPlugin
description: A legit xRay
depend: [ProtocolLib]
softdepend: [ProtocolLib]
api-version: 1.15

commands:
Expand Down
9 changes: 3 additions & 6 deletions xRay.iml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="inheritedJdk" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.15-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:1.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib:4.4.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib-API:4.4.0" level="project" />
Expand Down

0 comments on commit ca038f6

Please sign in to comment.