Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Prevent snowman trails; misc fixes #558

Merged
merged 2 commits into from
Dec 30, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ public void onDisable() {
}

if (playerManager != null) {
// make sure pets are properly removed on server shutdown
for (UltraPlayer player : playerManager.getUltraPlayers()) {
player.clear();
}

playerManager.dispose();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,13 @@ void initModule() {
ultraCosmetics.getSmartLogger().write("Initializing module " + serverVersion);

// mappings check is here so it's grouped with other NMS log messages
// bigger message so server owners might see it
if (!checkMappingsVersion(serverVersion)) {
ultraCosmetics.getSmartLogger().write(LogLevel.WARNING, "!!!!!!!!!!!!!!!!!!!!!!!!!!!! HEY YOU !!!!!!!!!!!!!!!!!!!!!!!!!!!!");
ultraCosmetics.getSmartLogger().write(LogLevel.WARNING, "Server internals seem to have changed since this build was created.");
ultraCosmetics.getSmartLogger().write(LogLevel.WARNING, "Please check for a server update and an UltraCosmetics update or you will likely experience issues.");
ultraCosmetics.getSmartLogger().write(LogLevel.WARNING, "Please check for a server update and an UltraCosmetics update.");
ultraCosmetics.getSmartLogger().write(LogLevel.WARNING, "UltraCosmetics will continue running but you will likely experience issues!");
ultraCosmetics.getSmartLogger().write(LogLevel.WARNING, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}

versionManager = new VersionManager(serverVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void common(CommandSender sender, String... args) {
}
Player opener = Bukkit.getPlayer(args[1]);
if (opener == null) {
sender.sendMessage("§c§lPlayer " + args[1] + " not found!");
sender.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "Player " + args[1] + " not found!");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import be.isach.ultracosmetics.cosmetics.type.PetType;
import be.isach.ultracosmetics.player.UltraPlayer;
import be.isach.ultracosmetics.util.ItemFactory;
import be.isach.ultracosmetics.util.ServerVersion;
import be.isach.ultracosmetics.util.UCMaterial;
import org.bukkit.Bukkit;
import org.bukkit.entity.Snowman;
Expand All @@ -18,6 +19,8 @@
public class PetSnowman extends Pet {
public PetSnowman(UltraPlayer owner, UltraCosmetics ultraCosmetics) {
super(owner, ultraCosmetics, PetType.getByName("snowman"), ItemFactory.create(UCMaterial.SNOWBALL, UltraCosmeticsData.get().getItemNoPickupString()));
// setDerp was added in 1.9, so skip the task if we're on 1.8
if (UltraCosmeticsData.get().getServerVersion() == ServerVersion.v1_8_R3) return;
Bukkit.getScheduler().runTaskLater(getUltraCosmetics(), () -> {
if (getOwner() != null && getEntity() != null) {
Snowman snowman = (Snowman) getEntity();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package be.isach.ultracosmetics.listeners;

import be.isach.ultracosmetics.UltraCosmeticsData;

import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.EntityBlockFormEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
Expand Down Expand Up @@ -41,4 +44,11 @@ public void onPlayerPickup(PlayerPickupItemEvent event) {
event.setCancelled(true);
}
}

@EventHandler
public void onSnowmanTrail(EntityBlockFormEvent event) {
if (event.getEntity().getType() != EntityType.SNOWMAN) return;
if (!event.getEntity().hasMetadata("Pet")) return;
event.setCancelled(true);
}
}