Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {

group = 'org.parallelmc'

version = '4.6.0'
version = '4.7.0'
description = 'A set of utilities and features for use on the Parallel Minecraft server'

java {
Expand All @@ -28,14 +28,14 @@ repositories {

dependencies {
//compileOnly 'io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT'
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.21.3-R0.1-SNAPSHOT")
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.21.5-R0.1-SNAPSHOT")

implementation 'org.jetbrains:annotations:24.0.1'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
implementation 'net.dv8tion:JDA:5.0.0-beta.24'
compileOnly 'me.clip:placeholderapi:2.11.6'
compileOnly fileTree('libs') { include '*.jar' }
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.12'
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.13'
implementation 'com.mysql:mysql-connector-j:8.3.0'
compileOnly 'com.comphenix.protocol:ProtocolLib:5.3.0'
compileOnly 'dev.esophose:playerparticles:8.7'
Expand Down Expand Up @@ -77,7 +77,7 @@ bukkit {

main = 'parallelmc.parallelutils.ParallelUtils'

apiVersion = '1.20.5'
apiVersion = '1.21.5'

depend = ['PlaceholderAPI', 'ProtocolLib']
softDepend = ['Multiverse-Core', 'FractalForest', 'WorldGuard', 'VoteParty', 'PlayerParticles', 'ProNouns']
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/parallelmc/parallelutils/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class Constants {

public static final Version VERSION = new Version(4, 6, 0);
public static final Version VERSION = new Version(4, 7, 0);
public static final String PLUGIN_NAME = "ParallelUtils";
public static final Component PLUGIN_PREFIX = MiniMessage.miniMessage()
.deserialize("<dark_aqua>[<white><bold>P</bold><dark_aqua>] <reset>");
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,6 @@ announcements:
disable-ender-chests: false
prevent-spawner-mining: false
enable-calling-bell: true
enable-cozy-campfires: true
enable-sweethearts: true
enable-ziprails: true
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import io.papermc.paperweight.userdev.ReobfArtifactConfiguration
plugins {
id 'java'
id 'io.github.goooler.shadow' version '8.1.7'
id "io.papermc.paperweight.userdev" version "1.7.4"
id "io.papermc.paperweight.userdev" version "2.0.0-beta.17"
id "xyz.jpenilla.run-paper" version "2.3.1"
id 'net.minecrell.plugin-yml.bukkit' version '0.6.0'
}
Expand All @@ -15,7 +15,7 @@ java {
paperweight.reobfArtifactConfiguration = ReobfArtifactConfiguration.getMOJANG_PRODUCTION()

dependencies {
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.21.3-R0.1-SNAPSHOT")
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.21.5-R0.1-SNAPSHOT")
}

compileJava.options.encoding = "UTF-8"
Expand All @@ -42,7 +42,7 @@ allprojects {
}

dependencies {
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.21.3-R0.1-SNAPSHOT")
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.21.5-R0.1-SNAPSHOT")
//paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT")

//compileOnly "io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions modules/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ dependencies {
compileOnly 'net.dv8tion:JDA:5.0.0-beta.24'
compileOnly 'me.clip:placeholderapi:2.11.6'
compileOnly fileTree('libs') { include '*.jar' }
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.12'
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.13'
compileOnly 'com.mysql:mysql-connector-j:8.3.0'
compileOnly 'com.comphenix.protocol:ProtocolLib:5.3.0'
compileOnly 'dev.esophose:playerparticles:8.7'
compileOnly "io.papermc.paper:paper-api:1.21.3-R0.1-SNAPSHOT"
compileOnly "io.papermc.paper:paper-api:1.21.5-R0.1-SNAPSHOT"
}

def names = []
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package parallelmc.parallelutils.modules.biometweaks;

import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.jetbrains.annotations.NotNull;
import parallelmc.parallelutils.Constants;
import parallelmc.parallelutils.ParallelClassLoader;
import parallelmc.parallelutils.ParallelModule;
import parallelmc.parallelutils.ParallelUtils;
import parallelmc.parallelutils.modules.biometweaks.biomes.PaleGarden;

import java.util.List;
import java.util.logging.Level;

public class BiomeTweaks extends ParallelModule {

public BiomeTweaks(ParallelClassLoader classLoader, List<String> dependents) {
super(classLoader, dependents);
}

@Override
public void onLoad() {

}

@Override
public void onEnable() {
PluginManager manager = Bukkit.getPluginManager();
Plugin plugin = manager.getPlugin(Constants.PLUGIN_NAME);

if (plugin == null) {
ParallelUtils.log(Level.SEVERE, "Unable to enable BiomeTweaks. Plugin " + Constants.PLUGIN_NAME + " does not exist!");
return;
}

ParallelUtils puPlugin = (ParallelUtils) plugin;

if (!puPlugin.registerModule(this)) {
ParallelUtils.log(Level.SEVERE, "Unable to register module BiomeTweaks! Module may already be registered. Quitting...");
return;
}

// Initialize individual biomes
PaleGarden paleGarden = new PaleGarden();
}

@Override
public void onDisable() {

}

@Override
public void onUnload() {

}

@Override
public @NotNull String getName() {
return "BiomeTweaks";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package parallelmc.parallelutils.modules.biometweaks.biomes;

import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import parallelmc.parallelutils.util.BukkitTools;
import parallelmc.parallelutils.util.RandomTools;


public class PaleGarden {

public PaleGarden() {
Plugin plugin = BukkitTools.getPlugin();
if (plugin == null) return;

plugin.getServer().getScheduler().runTaskTimer(plugin, this::gardenEffects, 0L, 20L);
}

public void gardenEffects() {
for (Player player : Bukkit.getOnlinePlayers()) {
Location location = player.getLocation();
// Check that player is in pale garden and at y=60 at minimum
if (location.getBlock().getBiome() == Biome.PALE_GARDEN && location.getY() >= 60) {
// Sound effects
player.playSound(location, Sound.BLOCK_CONDUIT_AMBIENT, SoundCategory.PLAYERS, 1, 1);
// 1/20 chance of ambient cave sound
if (RandomTools.betweenTwoNumbers(1, 20) == 1) {
player.playSound(location, Sound.AMBIENT_CAVE, SoundCategory.AMBIENT, 1, 1);
}
// 1/100 chance of thunder sound
if (RandomTools.betweenTwoNumbers(1, 100) == 1) {
player.playSound(location, Sound.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 1, 1);
}

// Particle effects
player.spawnParticle(Particle.FALLING_WATER, location.getX(), location.getY() + 20, location.getZ(),
200, 10, 10, 10, 4);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class BitsAndBobs extends ParallelModule {

private TogglePvpManager pvpManager;

private CozyCampfires cozyCampfires;

public BitsAndBobs(ParallelClassLoader classLoader, List<String> dependents) {
super(classLoader, dependents);
}
Expand Down Expand Up @@ -78,17 +80,22 @@ public void onEnable() {
manager.registerEvents(new PreventSpawnerMining(), plugin);
}

if (config.getBoolean("enable-ziprails", true)) {
manager.registerEvents(new Ziprails(), plugin);
}

if (config.getBoolean("enable-calling-bell", true)) {
manager.registerEvents(new CallingBell(), plugin);
}

cozyCampfires = new CozyCampfires();
if (config.getBoolean("enable-cozy-campfires", true)) {
plugin.getServer().getScheduler().runTaskTimer(plugin, () -> cozyCampfires.checkForCampfires(), 0, 80);
}

if (config.getBoolean("enable-sweethearts", true)) {
manager.registerEvents(new Sweethearts(), plugin);
}

if (config.getBoolean("enable-ziprails", true)) {
manager.registerEvents(new Ziprails(), plugin);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package parallelmc.parallelutils.modules.bitsandbobs.minimodules;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public class CozyCampfires {

private static final int RADIUS = 3;
private static final PotionEffect ABSORPTION = new PotionEffect(PotionEffectType.ABSORPTION, 14400, 1, true, false);

public void checkForCampfires() {
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (isCampfireNearby(p.getLocation())) {
p.addPotionEffect(ABSORPTION);
}
}
}

private boolean isCampfireNearby(Location location) {
World world = location.getWorld();
for (int x = -RADIUS; x <= RADIUS; x++) {
for (int y = -RADIUS; y <= RADIUS; y++) {
for (int z = -RADIUS; z <= RADIUS; z++) {
Block block = world.getBlockAt(add(location, x, y ,z));
if (block.getType() == Material.CAMPFIRE || block.getType() == Material.SOUL_CAMPFIRE) {
return true;
}
}
}
}
return false;
}

// spigot add no make copy
// this function make copy
// :)
private Location add(Location old, double x, double y, double z) {
return old.clone().add(x, y ,z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public void useSilenceNametag(PlayerInteractEntityEvent event) {
if (!player.getEquipment().getItem(slot).getType().equals(Material.NAME_TAG)) {
return;
}
if (!(event.getRightClicked() instanceof LivingEntity entity)) {
// If the player right clicked a non-living entity or a player, return
// This is to prevent a player accidentally editing another player's playerdata
if (!(event.getRightClicked() instanceof LivingEntity entity) || event.getRightClicked() instanceof Player) {
return;
}
TextComponent nametagName = (TextComponent) player.getEquipment().getItem(slot).getItemMeta().displayName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public class Ziprails implements Listener {

private static final double MINECART_DEFAULT_MAX_SPEED = 0.4d;
private static final double MINECART_DEFAULT_MAX_SPEED = 1.0d; // gamerule minecartMaxSpeed = 20
NamespacedKey key;

public Ziprails() {
Expand All @@ -29,7 +29,7 @@ public Ziprails() {

key = new NamespacedKey(plugin, "isZipping");

plugin.getServer().getScheduler().runTaskTimer(plugin, this::checkForZiprails, 0L, 4L);
plugin.getServer().getScheduler().runTaskTimer(plugin, this::checkForZiprails, 0L, 2L);
}

public void checkForZiprails() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import parallelmc.parallelutils.modules.charms.events.PlayerSlotChangedEvent;

import java.lang.reflect.Field;
import java.util.List;

public class PlayerJoinContainerListenerOverwrite implements Listener {

Expand Down Expand Up @@ -55,7 +56,7 @@ public void onJoin(PlayerJoinEvent event) {
if (oldSynchronizer != null) {
containerSynchronizer.set(serverPlayer, new ContainerSynchronizer() {
@Override
public void sendInitialData(@NotNull AbstractContainerMenu handler, @NotNull NonNullList<ItemStack> stacks, @NotNull ItemStack cursorStack, @NotNull int[] properties) {
public void sendInitialData(@NotNull AbstractContainerMenu handler, @NotNull List<ItemStack> stacks, @NotNull ItemStack cursorStack, @NotNull int[] properties) {
handler.lastSlots = NonNullListRemember.of(handler.lastSlots);
oldSynchronizer.sendInitialData(handler, stacks, cursorStack, properties);
}
Expand All @@ -74,6 +75,11 @@ public void sendCarriedChange(@NotNull AbstractContainerMenu handler, @NotNull I
public void sendDataChange(@NotNull AbstractContainerMenu handler, int property, int value) {
oldSynchronizer.sendDataChange(handler, property, value);
}

@Override
public RemoteSlot createSlot() {
return oldSynchronizer.createSlot();
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ PRIMARY KEY (shopID)
Location chestLoc = new Location(world, results.getInt("ChestX"), results.getInt("ChestY"), results.getInt("ChestZ"));
Location signLoc = new Location(world, results.getInt("SignX"), results.getInt("SignY"), results.getInt("SignZ"));
Material item = Material.getMaterial(results.getString("Item"));
if (item == null) {
ParallelUtils.log(Level.WARNING, "Skipping loading invalid ChestShop Material: " + results.getString("Item"));
continue;
}
int sellAmt = results.getInt("SellAmt");
int buyAmt = results.getInt("BuyAmt");
addShop(uuid, id, chestLoc, signLoc, item, sellAmt, buyAmt);
Expand Down Expand Up @@ -172,14 +176,18 @@ public void onDisable() {
conn.commit();
statement.close();

// this logic below needs to be redone at some point
// ideally shifting to a full database driven setup

// remove old chestshop entries that no longer exist on the server
// this helps fix conflicts where someone creates a shop where one recently existed (small edge case but good to patch)
// since existing chestshops have their timestamp updated automatically above, they shouldn't be touched by this
PreparedStatement cleanup = conn.prepareStatement("DELETE FROM ChestShops WHERE Timestamp < DATE_SUB(NOW(), INTERVAL 15 MINUTE)");
/* PreparedStatement cleanup = conn.prepareStatement("DELETE FROM ChestShops WHERE Timestamp < DATE_SUB(NOW(), INTERVAL 15 MINUTE)");
cleanup.setQueryTimeout(30);
cleanup.execute();
conn.commit();
cleanup.close();
*/

} catch (SQLException e) {
e.printStackTrace();
Expand Down
Loading