This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d84aef8
commit 0a87ba8
Showing
6 changed files
with
66 additions
and
23 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
49 changes: 49 additions & 0 deletions
49
src/main/java/xyz/hynse/foliaflow/util/CheckSafeTeleportation.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,49 @@ | ||
package xyz.hynse.foliaflow.util; | ||
|
||
import org.yaml.snakeyaml.Yaml; | ||
import xyz.hynse.foliaflow.FoliaFlow; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import static org.bukkit.Bukkit.getServer; | ||
|
||
public class CheckSafeTeleportation { | ||
|
||
public boolean checkUnsafeEndPortalTeleportation() { | ||
File configFile = new File(getServer().getWorldContainer(), "config/paper-global.yml"); | ||
if (!configFile.exists()) { | ||
FoliaFlow.instance.getLogger().warning("paper-global.yml not found!"); | ||
return false; | ||
} | ||
|
||
try (FileInputStream fis = new FileInputStream(configFile)) { | ||
Yaml yaml = new Yaml(); | ||
Map<String, Object> config = yaml.load(fis); | ||
|
||
Map<String, Object> unsupportedSettings = (Map<String, Object>) config.get("unsupported-settings"); | ||
if (unsupportedSettings != null) { | ||
Boolean setting = (Boolean) unsupportedSettings.get("allow-unsafe-end-portal-teleportation"); | ||
return setting != null && setting; | ||
} | ||
} catch (IOException e) { | ||
FoliaFlow.instance.getLogger().severe("Failed to read paper-global.yml: " + e.getMessage()); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
|
||
// public void updateSafeTeleportation() { | ||
// boolean safeTeleportation = checkUnsafeEndPortalTeleportation(); | ||
// if (safeTeleportation) { | ||
// FoliaFlow.instance.isUnSafeTeleport = true; | ||
// FoliaFlow.instance.getLogger().info("Unsafe End Portal Teleportation is true."); | ||
// } else { | ||
// FoliaFlow.instance.isUnSafeTeleport = false; | ||
// FoliaFlow.instance.getLogger().info("Unsafe End Portal Teleportation is false."); | ||
// } | ||
// } | ||
} |
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