-
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.
- Loading branch information
0 parents
commit d8fc8dd
Showing
7 changed files
with
181 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
### IntelliJ IDEA ### | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
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,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="FacetManager"> | ||
<facet type="minecraft" name="Minecraft"> | ||
<configuration> | ||
<autoDetectTypes> | ||
<platformType>SPIGOT</platformType> | ||
<platformType>MCP</platformType> | ||
</autoDetectTypes> | ||
<projectReimportVersion>1</projectReimportVersion> | ||
</configuration> | ||
</facet> | ||
</component> | ||
<component name="McpModuleSettings"> | ||
<option name="srgType" value="SRG" /> | ||
</component> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_21" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="jdk" jdkName="21" jdkType="JavaSDK" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="1_20_6_LIBS" level="application" /> | ||
<orderEntry type="library" name="projectlombok.lombok" level="application" /> | ||
</component> | ||
</module> |
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,4 @@ | ||
Translations: | ||
Console: "<gray>Prevented teleport of player <yellow>{0}</yellow></gray> using <blue>{1}</blue>" # {0} = player's nickname, {1} = teleport cause (ender_pearl/chorus_fruit) | ||
Player: "<red>Hey! You can't teleport using <yellow>{0}</yellow> outside the border!</red>" # {0} teleport cause (same like above) | ||
|
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,27 @@ | ||
package me.petulikan1.PearlFix; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.World; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerTeleportEvent; | ||
|
||
public class EventListener implements Listener { | ||
|
||
@EventHandler | ||
public void onTeleport(PlayerTeleportEvent e) { | ||
if (e.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL || e.getCause() == PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT) { | ||
Location to = e.getTo(); | ||
World world = to.getWorld(); | ||
if (!world.getWorldBorder().isInside(to)) { | ||
e.setCancelled(true); | ||
Utils.msg("Console", Bukkit.getConsoleSender(), e.getPlayer().getName(), e.getCause()); | ||
Utils.msg("Player", e.getPlayer(), e.getCause()); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
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,28 @@ | ||
package me.petulikan1.PearlFix; | ||
|
||
import lombok.Getter; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public class Loader extends JavaPlugin { | ||
|
||
|
||
private EventListener listener = null; | ||
@Getter | ||
protected static Loader main; | ||
|
||
@Override | ||
public void onEnable() { | ||
main = this; | ||
Bukkit.getPluginManager().registerEvents(listener = new EventListener(), this); | ||
saveDefaultConfig(); | ||
} | ||
|
||
|
||
@Override | ||
public void onDisable() { | ||
if (listener != null) | ||
HandlerList.unregisterAll(listener); | ||
} | ||
} |
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,61 @@ | ||
package me.petulikan1.PearlFix; | ||
|
||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.minimessage.MiniMessage; | ||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; | ||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; | ||
import net.kyori.adventure.translation.Translatable; | ||
import org.bukkit.command.CommandSender; | ||
|
||
public class Utils { | ||
|
||
private final static PlainTextComponentSerializer plainTextComponentSerializer = PlainTextComponentSerializer.builder().build(); | ||
|
||
private final static LegacyComponentSerializer legacySection | ||
= LegacyComponentSerializer.legacySection().toBuilder().useUnusualXRepeatedCharacterHexFormat().hexColors().extractUrls() | ||
.build(); | ||
|
||
private static final MiniMessage mm = MiniMessage.builder().build(); | ||
|
||
public static <T extends Translatable> String plainText(T t) { | ||
return plainTextComponentSerializer.serialize(Component.translatable(t)); | ||
} | ||
|
||
public static String plainText(String msg) { | ||
return mm.serialize(legacySection.deserialize(plainTextComponentSerializer.serialize(Component.text(msg)))); | ||
} | ||
|
||
public static String getTranslation(String key) { | ||
return Loader.getMain().getConfig().getString("Translations." + key, "NO_TRANSLATION_FOUND!"); | ||
} | ||
|
||
public static void msg(String key, CommandSender s) { | ||
if (s == null) | ||
throw new RuntimeException("CommandSender can't be null!"); | ||
s.sendMessage(component(key)); | ||
} | ||
|
||
public static void msg(String key, CommandSender s, Object... objects) { | ||
if (s == null) | ||
throw new RuntimeException("CommandSender can't be null!"); | ||
s.sendMessage(component(key, objects)); | ||
} | ||
|
||
public static Component component(String key) { | ||
return mm.deserialize(getTranslation(key)); | ||
} | ||
|
||
public static Component component(String key, Object... objects) { | ||
return mm.deserialize(replacedTranslation(key, objects)); | ||
} | ||
|
||
public static String replacedTranslation(String key, Object... objects) { | ||
String translation = getTranslation(key); | ||
int i = 0; | ||
for (Object o : objects) { | ||
translation = translation.replace("{" + i + "}", o + ""); | ||
i++; | ||
} | ||
return translation; | ||
} | ||
} |
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,5 @@ | ||
main: me.petulikan1.PearlFix.Loader | ||
name: PearlFix | ||
author: petulikan1 | ||
version: 1.0 | ||
website: https://github.com/petulikan1 |