Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into folia
Browse files Browse the repository at this point in the history
# Conflicts:
#	Prism/build.gradle
  • Loading branch information
Rothes committed Feb 24, 2024
2 parents 9b4468a + 7429a3e commit 1729496
Show file tree
Hide file tree
Showing 34 changed files with 1,017 additions and 126 deletions.
2 changes: 1 addition & 1 deletion Prism-Api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ version = project.property("version")
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
compileOnly 'org.jetbrains:annotations:23.0.0'
}

Expand Down
13 changes: 8 additions & 5 deletions Prism/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ repositories {

// PasteGG
maven { url = 'https://maven.addstar.com.au/artifactory/all-snapshot' }

// Adventure snapshot
maven { url = 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
}

group = project.property("group")
Expand All @@ -40,17 +43,17 @@ dependencies {
// Allows Java 1.8
targetConfiguration = "compile"
}
compileOnly 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT'

compileOnly 'org.spigotmc:spigot-api:1.20.3-R0.1-SNAPSHOT'
compileOnly('com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT') {
exclude group: 'org.spigotmc', module: 'spigot-api'
}
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'io.papermc:paperlib:1.0.3'
implementation 'com.zaxxer:HikariCP:4.0.3'
implementation 'net.kyori:adventure-api:4.11.0'
implementation 'net.kyori:adventure-platform-bukkit:4.1.2'
implementation 'net.kyori:adventure-text-serializer-plain:4.11.0'
implementation 'net.kyori:adventure-api:4.15.0'
// implementation 'net.kyori:adventure-platform-bukkit:4.3.1' // Not for 1.20.3/4
implementation 'net.kyori:adventure-platform-bukkit:4.3.2-SNAPSHOT'
implementation 'net.kyori:adventure-text-serializer-plain:4.15.0'
implementation 'org.kitteh:paste-gg-api:1.0.0-SNAPSHOT'
implementation project(':Prism-Api')
}
Expand Down
2 changes: 1 addition & 1 deletion Prism/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=3.7.0-SNAPSHOT
version=3.8.0
apiversion=1.16
5 changes: 2 additions & 3 deletions Prism/src/main/java/network/darkhelmet/prism/Messenger.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ public Messenger(String pluginName, AudienceProvider provider) {
*/
public void sendMessage(CommandSender sender, Component message) {
if (sender instanceof ConsoleCommandSender) {
audienceProvider.console().sendMessage(Identity.nil(),message);
audienceProvider.console().sendMessage(message);
} else {
((BukkitAudiences) audienceProvider).sender(sender).sendMessage(Identity.nil(),
message.colorIfAbsent(defaultColor));
((BukkitAudiences) audienceProvider).sender(sender).sendMessage(message.colorIfAbsent(defaultColor));
}
}

Expand Down
11 changes: 10 additions & 1 deletion Prism/src/main/java/network/darkhelmet/prism/Prism.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public class Prism extends JavaPlugin implements PrismApi {
private static String baseUrl = "https://prism-bukkit.readthedocs.io/en/latest/";
public static Messenger messenger;
public static FileConfiguration config;
public static boolean isSpigot = true;
public static boolean isPaper = true;
public static boolean isFolia = false;
private static Logger prismLog;
Expand Down Expand Up @@ -144,6 +145,7 @@ public class Prism extends JavaPlugin implements PrismApi {
public int totalRecordsAffected = 0;
public long maxCycleTime = 0;
private byte serverMajorVersion;
private byte serverMinorVersion;

/**
* We store a basic index of hanging entities we anticipate will fall, so that
Expand Down Expand Up @@ -376,6 +378,10 @@ public byte getServerMajorVersion() {
return serverMajorVersion;
}

public byte getServerMinorVersion() {
return serverMinorVersion;
}

/**
* Enables the plugin and activates our player listeners.
*/
Expand All @@ -388,8 +394,11 @@ public void onEnable() {
audiences = BukkitAudiences.create(this);
messenger = new Messenger(pluginName, Prism.getAudiences());
log("Initializing Prism " + pluginVersion + ". by viveleroi");
serverMajorVersion = Byte.parseByte(Bukkit.getServer().getBukkitVersion().split("\\.")[1].split("-")[0]);
String[] split = Bukkit.getServer().getBukkitVersion().split("\\.");
serverMajorVersion = Byte.parseByte(split[1].split("-")[0]);
serverMinorVersion = split.length > 2 ? Byte.parseByte(split[2].split("-")[0]) : 0;
loadConfig(); // Load configuration, or install if new
isSpigot = PaperLib.isSpigot();
isPaper = PaperLib.isPaper();
if (isPaper) {
Prism.log("Optional Paper Events will be enabled.");
Expand Down
4 changes: 4 additions & 0 deletions Prism/src/main/java/network/darkhelmet/prism/PrismConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public FileConfiguration getConfig() {
config.addDefault("prism.tracking.container-access", true);
config.addDefault("prism.tracking.cake-eat", true);
config.addDefault("prism.tracking.craft-item", false);
config.addDefault("prism.tracking.upgrade-gear", false);
config.addDefault("prism.tracking.creeper-explode", true);
config.addDefault("prism.tracking.crop-trample", true);
config.addDefault("prism.tracking.dragon-eat", true);
Expand All @@ -152,6 +153,7 @@ public FileConfiguration getConfig() {
config.addDefault("prism.tracking.fireball", true);
config.addDefault("prism.tracking.fire-spread", false);
config.addDefault("prism.tracking.firework-launch", true);
config.addDefault("prism.tracking.flowerpot-change", true);
config.addDefault("prism.tracking.hangingitem-break", true);
config.addDefault("prism.tracking.hangingitem-place", true);
config.addDefault("prism.tracking.item-drop", true);
Expand Down Expand Up @@ -181,6 +183,8 @@ public FileConfiguration getConfig() {
config.addDefault("prism.tracking.potion-splash", true);
config.addDefault("prism.tracking.sheep-eat", true);
config.addDefault("prism.tracking.sign-change", true);
config.addDefault("prism.tracking.sign-dye", true);
config.addDefault("prism.tracking.sign-glow", true);
config.addDefault("prism.tracking.spawnegg-use", true);
config.addDefault("prism.tracking.target-hit", false);
config.addDefault("prism.tracking.tnt-explode", true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
package network.darkhelmet.prism.actionlibs;

import network.darkhelmet.prism.actions.BlockAction;
import network.darkhelmet.prism.actions.BlockChangeAction;
import network.darkhelmet.prism.actions.BlockFallAction;
import network.darkhelmet.prism.actions.BlockShiftAction;
import network.darkhelmet.prism.actions.EntityAction;
import network.darkhelmet.prism.actions.EntityTravelAction;
import network.darkhelmet.prism.actions.GrowAction;
import network.darkhelmet.prism.actions.HangingItemAction;
import network.darkhelmet.prism.actions.ItemStackAction;
import network.darkhelmet.prism.actions.PlayerAction;
import network.darkhelmet.prism.actions.PlayerDeathAction;
import network.darkhelmet.prism.actions.PortalCreateAction;
import network.darkhelmet.prism.actions.PrismProcessAction;
import network.darkhelmet.prism.actions.PrismRollbackAction;
import network.darkhelmet.prism.actions.SignAction;
import network.darkhelmet.prism.actions.UseAction;
import network.darkhelmet.prism.actions.VehicleAction;
import network.darkhelmet.prism.actions.*;
import network.darkhelmet.prism.api.actions.Handler;
import network.darkhelmet.prism.api.actions.PrismProcessType;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
Expand Down Expand Up @@ -174,6 +159,20 @@ public static Handler createBlockChange(String actionType, Location loc, Materia
return a;
}

/**
* PlayerInteractEvent.
*
*/
public static Handler createFlowerPotChange(Block oldBlock, Material newMat, OfflinePlayer player) {
final FlowerPotChangeAction a = new FlowerPotChangeAction();
a.setActionType("flowerpot-change");
a.setLoc(oldBlock.getLocation());
a.setOldMaterial(oldBlock.getType());
a.setMaterial(newMat);
a.setPlayer(player);
return a;
}

/**
* BlockShiftAction.
*
Expand Down Expand Up @@ -554,17 +553,45 @@ public static Handler createPrismRollback(String actionType, BlockState oldBlock
}

/**
* SignAction.
* SignChangeAction.
*
* @param actionType the action
* @param block the block acted on
* @param player the acting player
*/
public static Handler createSign(String actionType, Block block, String[] lines, OfflinePlayer player) {
final SignAction a = new SignAction();
public static Handler createSignChange(String actionType, Block block, String[] lines, boolean isFront, OfflinePlayer player) {
final SignChangeAction a = new SignChangeAction();
a.setActionType(actionType);
a.setPlayer(player);
a.setBlock(block, lines);
a.setBlock(block, lines, isFront);
return a;
}

/**
* PlayerInteractEvent.
*
* @param block the block acted on
* @param player the acting player
*/
public static Handler createSignDye(Block block, DyeColor color, boolean isFront, OfflinePlayer player) {
final SignDyeAction a = new SignDyeAction();
a.setActionType("sign-dye");
a.setPlayer(player);
a.setBlock(block, color, isFront);
return a;
}

/**
* PlayerInteractEvent.
*
* @param block the block acted on
* @param player the acting player
*/
public static Handler createSignGlow(Block block, boolean makeGlow, boolean isFront, OfflinePlayer player) {
final SignGlowAction a = new SignGlowAction();
a.setActionType("sign-glow");
a.setPlayer(player);
a.setBlock(block, makeGlow, isFront);
return a;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public void setResultIndex(int index) {
* @return String
*/
public String getRawMessage() {
String format1 = "<prefix> <handlerId> <target> <actor> <extendedInfo><actorNice><count>"
+ "<timeDiff> <location>";
String format1 = "<prefix> <handlerId> <target> <actor> <actorNice> <count>"
+ "<dateTime> (<timeDiff>) <location>";
ActionType action = handler.getActionType();
return PlainComponentSerializer.plain().serialize(getMainMessage(action, format1));
}
Expand All @@ -72,6 +72,11 @@ private TextComponent getMainMessage(ActionType action, String format1) {
builder -> Component.text().append(getExtendedInfo()))
.replaceFirstText(Pattern.compile("<timeDiff>"),
builder -> Component.text().append(getTimeDiff()))
.replaceFirstText(Pattern.compile("<dateTime>"),
builder -> Component.text()
.content(handler.getDisplayDate() + " " + handler.getDisplayTime()))
.replaceFirstText(Pattern.compile("<location>"),
builder -> Component.text().content(getFormattedLocation()))
.replaceFirstText(Pattern.compile("<count>"),
builder -> Component.text().append(getCount()))
.replaceFirstText(Pattern.compile("<actionType>"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,7 @@

import network.darkhelmet.prism.Il8nHelper;
import network.darkhelmet.prism.Prism;
import network.darkhelmet.prism.actions.BlockAction;
import network.darkhelmet.prism.actions.BlockChangeAction;
import network.darkhelmet.prism.actions.BlockFallAction;
import network.darkhelmet.prism.actions.BlockShiftAction;
import network.darkhelmet.prism.actions.EntityAction;
import network.darkhelmet.prism.actions.EntityTravelAction;
import network.darkhelmet.prism.actions.GrowAction;
import network.darkhelmet.prism.actions.HangingItemAction;
import network.darkhelmet.prism.actions.ItemStackAction;
import network.darkhelmet.prism.actions.PlayerAction;
import network.darkhelmet.prism.actions.PlayerDeathAction;
import network.darkhelmet.prism.actions.PortalCreateAction;
import network.darkhelmet.prism.actions.PrismProcessAction;
import network.darkhelmet.prism.actions.PrismRollbackAction;
import network.darkhelmet.prism.actions.SignAction;
import network.darkhelmet.prism.actions.UseAction;
import network.darkhelmet.prism.actions.VehicleAction;
import network.darkhelmet.prism.actions.*;
import network.darkhelmet.prism.exceptions.InvalidActionException;
import network.darkhelmet.prism.utils.TypeUtils;
import org.bukkit.plugin.Plugin;
Expand Down Expand Up @@ -171,6 +155,8 @@ private void registerPrismDefaultActions() {
BlockAction.class, Il8nHelper.getRawMessage("accessed")));
registerAction(new ActionTypeImpl("craft-item", false, false, false,
ItemStackAction.class, Il8nHelper.getRawMessage("crafted")));
registerAction(new ActionTypeImpl("upgrade-gear", false, false, false,
ItemStackAction.class, Il8nHelper.getRawMessage("upgraded")));
registerAction(new ActionTypeImpl("creeper-explode", false, true, true,
BlockAction.class, Il8nHelper.getRawMessage("blew-up")));
registerAction(new ActionTypeImpl("crop-trample", false, true, true,
Expand Down Expand Up @@ -209,6 +195,8 @@ private void registerPrismDefaultActions() {
BlockChangeAction.class, Il8nHelper.getRawMessage("spread")));
registerAction(new ActionTypeImpl("firework-launch", false, false, false,
ItemStackAction.class, Il8nHelper.getRawMessage("launched")));
registerAction(new ActionTypeImpl("flowerpot-change", false, true, true,
FlowerPotChangeAction.class, Il8nHelper.getRawMessage("flowerpot-changed")));
registerAction(new ActionTypeImpl("hangingitem-break", false, true, true,
HangingItemAction.class, Il8nHelper.getRawMessage("broke")));
registerAction(new ActionTypeImpl("hangingitem-place", true, true, true,
Expand Down Expand Up @@ -271,8 +259,12 @@ private void registerPrismDefaultActions() {
PrismRollbackAction.class, Il8nHelper.getRawMessage("rolled-back")));
registerAction(new ActionTypeImpl("sheep-eat", false, false, false,
BlockAction.class, Il8nHelper.getRawMessage("ate")));
registerAction(new ActionTypeImpl("sign-change", false, false, true,
SignAction.class, Il8nHelper.getRawMessage("wrote")));
registerAction(new ActionTypeImpl("sign-change", false, true, true,
SignChangeAction.class, Il8nHelper.getRawMessage("wrote")));
registerAction(new ActionTypeImpl("sign-dye", false, true, true,
SignDyeAction.class, Il8nHelper.getRawMessage("sign-dyed")));
registerAction(new ActionTypeImpl("sign-glow", false, true, true,
SignGlowAction.class, Il8nHelper.getRawMessage("sign-glowed")));
registerAction(new ActionTypeImpl("spawnegg-use", false, false, false,
UseAction.class, Il8nHelper.getRawMessage("used")));
registerAction(new ActionTypeImpl("tnt-explode", false, true, true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import network.darkhelmet.prism.actions.PortalCreateAction;
import network.darkhelmet.prism.actions.PrismProcessAction;
import network.darkhelmet.prism.actions.PrismRollbackAction;
import network.darkhelmet.prism.actions.SignAction;
import network.darkhelmet.prism.actions.SignChangeAction;
import network.darkhelmet.prism.actions.UseAction;
import network.darkhelmet.prism.actions.VehicleAction;
import network.darkhelmet.prism.api.actions.Handler;
Expand Down Expand Up @@ -85,7 +85,7 @@ private void registerPrismDefaultHandlers() {
registeredHandlers.add(PortalCreateAction.class);
registeredHandlers.add(PrismProcessAction.class);
registeredHandlers.add(PrismRollbackAction.class);
registeredHandlers.add(SignAction.class);
registeredHandlers.add(SignChangeAction.class);
registeredHandlers.add(UseAction.class);
registeredHandlers.add(VehicleAction.class);
}
Expand Down
Loading

0 comments on commit 1729496

Please sign in to comment.