-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from TWME-TW/clean-code-0103
Fixed an issue when transferring a large number of chunks
- Loading branch information
Showing
10 changed files
with
111 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/dev/twme/worldeditsync/paper/UpdateChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package dev.twme.worldeditsync.paper; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URI; | ||
import java.util.Scanner; | ||
import java.util.function.Consumer; | ||
|
||
public class UpdateChecker { | ||
|
||
private final JavaPlugin plugin; | ||
private final int resourceId; | ||
|
||
public UpdateChecker(JavaPlugin plugin, int resourceId) { | ||
this.plugin = plugin; | ||
this.resourceId = resourceId; | ||
} | ||
|
||
public void getVersion(final Consumer<String> consumer) { | ||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> { | ||
URI uri = URI.create("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId); | ||
try (InputStream is = uri.toURL().openStream(); Scanner scann = new Scanner(is)) { | ||
if (scann.hasNext()) { | ||
consumer.accept(scann.next()); | ||
} | ||
} catch (IOException e) { | ||
plugin.getLogger().info("Unable to check for updates: " + e.getMessage()); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
src/main/java/dev/twme/worldeditsync/paper/worldedit/WorldEditHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters