Skip to content

Commit

Permalink
Merge pull request #95 from teakivy/spigot
Browse files Browse the repository at this point in the history
Spigot Support
  • Loading branch information
teakivy committed Jul 7, 2024
2 parents 264cb89 + 276df4e commit e769736
Show file tree
Hide file tree
Showing 52 changed files with 599 additions and 202 deletions.
105 changes: 80 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,55 @@

<description>150+ Toggleable Tweaks &amp; Features including Vanilla Tweaks as a plugin, and more!</description>
<properties>
<java.version>14</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>
<url>https://twitter.com/TeakIvyYT</url>

<build>
<finalName>TeaksTweaks - ${project.version}</finalName>
<!-- <finalName>TeaksTweaks - DEV</finalName>-->
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>2.0.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.21-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.21-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.21-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.21-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>16</source>
<target>16</target>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -47,25 +80,25 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerId>eclipse</compilerId>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<dependencies>
<!-- Compiler -->
<!-- The default compiler has troubles with the class PlayerDataInfo -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.8.8</version>
</dependency>
</dependencies>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <version>3.8.1</version>-->
<!-- <configuration>-->
<!-- <compilerId>eclipse</compilerId>-->
<!-- <source>${java.version}</source>-->
<!-- <target>${java.version}</target>-->
<!-- </configuration>-->
<!-- <dependencies>-->
<!-- &lt;!&ndash; Compiler &ndash;&gt;-->
<!-- &lt;!&ndash; The default compiler has troubles with the class PlayerDataInfo &ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>org.codehaus.plexus</groupId>-->
<!-- <artifactId>plexus-compiler-eclipse</artifactId>-->
<!-- <version>2.8.8</version>-->
<!-- </dependency>-->
<!-- </dependencies>-->
<!-- </plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down Expand Up @@ -108,16 +141,38 @@

<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<classifier>remapped-mojang</classifier>
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.bukkit</groupId>-->
<!-- <artifactId>bukkit</artifactId>-->
<!-- <version>1.21-R0.1-SNAPSHOT</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.25</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.3.3</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</project>
19 changes: 19 additions & 0 deletions src/main/java/me/teakivy/teakstweaks/TeaksTweaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import me.teakivy.teakstweaks.utils.metrics.Metrics;
import me.teakivy.teakstweaks.utils.update.UpdateChecker;
import me.teakivy.teakstweaks.utils.update.UpdateJoinAlert;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
Expand All @@ -25,14 +26,28 @@
public final class TeaksTweaks extends JavaPlugin implements Listener {
private final ArrayList<String> activePacks = new ArrayList<>();
private final ArrayList<String> activeCraftingTweaks = new ArrayList<>();
private BukkitAudiences adventure;

private Register register;


public BukkitAudiences adventure() {
if(this.adventure == null) {
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
}
return this.adventure;
}

public static BukkitAudiences getAdventure() {
return getInstance().adventure();
}
/**
* Called when the plugin is enabled
*/
@Override
public void onEnable() {
// Initialize an audiences instance for the plugin
this.adventure = BukkitAudiences.create(this);
// Credits
createCredits();

Expand Down Expand Up @@ -81,6 +96,10 @@ public void onEnable() {
*/
@Override
public void onDisable() {
if(this.adventure != null) {
this.adventure.close();
this.adventure = null;
}
// Plugin shutdown logic
Logger.info(Translatable.get("startup.plugin.shutting_down"));
}
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/me/teakivy/teakstweaks/commands/AltsCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void playerCommand(PlayerCommandEvent event) {
String action = event.getArg(0);

if (event.hasArgs(2)) {
secondary = Bukkit.getPlayerUniqueId(event.getArg(1));
secondary = getUUID(event.getArg(1));

if (secondary == null) {
sendError(ErrorType.PLAYER_DNE);
Expand All @@ -39,7 +39,7 @@ public void playerCommand(PlayerCommandEvent event) {
return;
}

main = Bukkit.getPlayerUniqueId(event.getArg(2));
main = getUUID(event.getArg(2));

if (main == null) {
sendError(ErrorType.PLAYER_DNE);
Expand Down Expand Up @@ -159,4 +159,13 @@ public boolean canAddAlt(Player player) {
if (getPackConfig().getInt("max-alts") == -1) return true;
return SpectatorAlts.getAlts(player.getUniqueId()).size() < getPackConfig().getInt("max-alts");
}

private UUID getUUID(String name) {
for (OfflinePlayer p : Bukkit.getOfflinePlayers()) {
if (p.getName().equalsIgnoreCase(name)) {
return p.getUniqueId();
}
}
return null;
}
}
7 changes: 4 additions & 3 deletions src/main/java/me/teakivy/teakstweaks/commands/TPACommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import me.teakivy.teakstweaks.TeaksTweaks;
import me.teakivy.teakstweaks.packs.teleportation.back.Back;
import me.teakivy.teakstweaks.utils.ErrorType;
import me.teakivy.teakstweaks.utils.MM;
import me.teakivy.teakstweaks.utils.command.*;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
Expand Down Expand Up @@ -67,7 +68,7 @@ public void playerCommand(PlayerCommandEvent event) {
TPARequest req = new TPARequest(player, to);
requests.add(req);

to.sendMessage(message);
MM.player(to).sendMessage(message);
sendMessage("request_sent", insert("player", to.getName()));

Bukkit.getScheduler().scheduleSyncDelayedTask(TeaksTweaks.getInstance(), () -> {
Expand Down Expand Up @@ -164,8 +165,8 @@ public void accept() {
accepted = true;
Back.backLoc.put(to.getUniqueId(), to.getLocation());
from.teleport(to.getLocation());
to.sendMessage(getText("teleporting_to_you", insert("player", from.getName())));
from.sendMessage(getText("teleporting", insert("player", to.getName())));
MM.player(to).sendMessage(getText("teleporting_to_you", insert("player", from.getName())));
MM.player(from).sendMessage(getText("teleporting", insert("player", to.getName())));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -36,7 +37,7 @@ public void playerCommand(PlayerCommandEvent event) {

if (team == null) {
team = sb.registerNewTeam("TaggedTeam");
team.color(NamedTextColor.RED);
team.setColor(ChatColor.RED);
}

team.addEntry(player.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
public class TeaksTweaksCommand extends AbstractCommand {

public TeaksTweaksCommand() {
super(CommandType.ALL, null, "teakstweaks", Arrays.asList("tweaks", "tt"), "teakstweakscommand", Arg.required("info", "version", "support", "update"));
super(CommandType.ALL, null, "teakstweaks", Arrays.asList("tweaks", "tt"), "teakstweakscommand", Arg.optional("info", "version", "support", "update"));
}

@Override
public void command(CommandEvent event) {
if (!event.hasArgs()) {
sendInfoMessage();
return;
}
switch (event.getArg(0)) {
case "info":
sendInfoMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import me.teakivy.teakstweaks.TeaksTweaks;
import me.teakivy.teakstweaks.packs.PackType;
import me.teakivy.teakstweaks.utils.Logger;
import me.teakivy.teakstweaks.utils.MM;
import me.teakivy.teakstweaks.utils.config.Config;
import me.teakivy.teakstweaks.utils.lang.Translatable;
import me.teakivy.teakstweaks.utils.metrics.CustomMetrics;
Expand All @@ -12,6 +13,7 @@
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -66,14 +68,14 @@ public void init() {

lore.add(PackType.CRAFTING_TWEAKS.getName());

List<Component> components = new ArrayList<>();
List<String> components = new ArrayList<>();
for (String l : lore) {
components.add(MiniMessage.miniMessage().deserialize(l).decoration(TextDecoration.ITALIC, false));
components.add(MM.toString(MiniMessage.miniMessage().deserialize(l).decoration(TextDecoration.ITALIC, false)));
}

item.lore(components);

item.editMeta(meta -> meta.displayName(MiniMessage.miniMessage().deserialize(PackType.CRAFTING_TWEAKS.getColor() + name).decoration(TextDecoration.ITALIC, false)));
ItemMeta meta = item.getItemMeta();
meta.setLore(components);
meta.setDisplayName(MM.toString(MiniMessage.miniMessage().deserialize(PackType.CRAFTING_TWEAKS.getColor() + name).decoration(TextDecoration.ITALIC, false)));
item.setItemMeta(meta);
}

/**
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/me/teakivy/teakstweaks/packs/BasePack.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import me.teakivy.teakstweaks.TeaksTweaks;
import me.teakivy.teakstweaks.utils.Logger;
import me.teakivy.teakstweaks.utils.MM;
import me.teakivy.teakstweaks.utils.config.Config;
import me.teakivy.teakstweaks.utils.lang.Translatable;
import me.teakivy.teakstweaks.utils.metrics.CustomMetrics;
Expand All @@ -17,6 +18,7 @@
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.intellij.lang.annotations.Subst;

import java.util.ArrayList;
Expand Down Expand Up @@ -76,13 +78,15 @@ public BasePack(String path, PackType packType, Material material) {

lore.add(packType.getColor() + packType.getName());

List<Component> loreComponents = new ArrayList<>();
List<String> loreComponents = new ArrayList<>();
for (String line : lore) {
loreComponents.add(MiniMessage.miniMessage().deserialize("<reset>" + line).decoration(TextDecoration.ITALIC, false));
loreComponents.add(MM.toString(MiniMessage.miniMessage().deserialize("<reset>" + line).decoration(TextDecoration.ITALIC, false)));
}

item.lore(loreComponents);
item.editMeta(meta -> meta.displayName(MiniMessage.miniMessage().deserialize(packType.getColor() + name).decoration(TextDecoration.ITALIC, false)));
ItemMeta meta = item.getItemMeta();
meta.setLore(loreComponents);
meta.setDisplayName(MM.toString(MiniMessage.miniMessage().deserialize(packType.getColor() + name).decoration(TextDecoration.ITALIC, false)));
item.setItemMeta(meta);

CustomMetrics.addPackEnabled(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void onPrime(ExplosionPrimeEvent event) {

Firework fw = (Firework) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.FIREWORK_ROCKET);
FireworkMeta fwMeta = fw.getFireworkMeta();
fwMeta.displayName(Component.text("Confetti"));
fwMeta.setDisplayName("Confetti");
fwMeta.addEffect(fwEffect);
fw.setFireworkMeta(fwMeta);
fw.detonate();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.teakivy.teakstweaks.packs.experimental.elevators;

import com.destroystokyo.paper.event.player.PlayerJumpEvent;
import me.teakivy.teakstweaks.packs.BasePack;
import me.teakivy.teakstweaks.packs.PackType;
import org.bukkit.*;
Expand All @@ -12,6 +11,7 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
Expand Down Expand Up @@ -84,8 +84,9 @@ public void onSneak(PlayerToggleSneakEvent event) {
}

@EventHandler
public void onJump(PlayerJumpEvent e) {
public void onJump(PlayerMoveEvent e) {
Player player = e.getPlayer();
if (e.getFrom().getY() < e.getTo().getY()) return;
Location loc = player.getLocation();
Block standingBlock = loc.add(0, -1, 0).getBlock();
if (!isElevator(standingBlock)) return;
Expand Down
Loading

0 comments on commit e769736

Please sign in to comment.