Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

Commit

Permalink
Updated to 0.4.2, switched to Linux. (lot of line ending null edits, …
Browse files Browse the repository at this point in the history
…sorry!)
  • Loading branch information
xPXpanD committed Jun 19, 2020
1 parent a536290 commit 84b6f8c
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 48 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
0.4.2 for ???
Released ???
0.4.2 for 8.0.0
Released June 19th, 2020.

Additions:
* Added support for showing Galarians in broadcasts.

Tweaks:
* Removed the "PBR //" fluff from console messages as the sidemod name is already shown.
* Removed the config helper that automatically turns off Pixelmon's legendary message due to mod updates breaking it.

Fixes:
* Fixed the horrible spam/crashing from Alolans being moved to a different enum in Pixelmon.
* Worked around Bind causing a NullPointerException on the Faint event listener. (likely a Pixelmon bug)

0.4.1 for 7.0.5
Released May 15th, 2019.
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle.forge'

// Sets the version number shown in the file name.
version = "1.12.2-0.4.1"
version = "1.12.2-0.4.2"

// Taken from the internet. vvv
sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly.
Expand All @@ -29,8 +29,8 @@ compileJava
tasks.withType(JavaCompile)
{
task ->
task.options.encoding = 'UTF-8'
task.options.fork = true
task.options.encoding = 'UTF-8'
task.options.fork = true
}

// Basic info for what we're compiling against and how we're doing it, I think?
Expand Down
35 changes: 16 additions & 19 deletions src/main/java/rs/expand/pixelmonbroadcasts/PixelmonBroadcasts.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import rs.expand.pixelmonbroadcasts.listeners.*;
import rs.expand.pixelmonbroadcasts.utilities.ConfigMethods;

import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -59,14 +58,15 @@
// FIXME: Similarly, Pokémon names seem to be English as well.
// FIXME: Challenges and forfeits can be used to spam servers. Add a persistent tag to avoid repeats?
// NOTE: Be careful with grabbing stuff directly from event players, they occasionally go null.
// TODO: Add Alolans/Galarians to the logger.

@Plugin
(
id = "pixelmonbroadcasts",
name = "PixelmonBroadcasts",
version = "0.4.1",
version = "0.4.2",
dependencies = {
@Dependency(id = "pixelmon", version = "7.0.5"),
@Dependency(id = "pixelmon", version = "8.0.0"),
@Dependency(id = "pixelmonoverlay", version = "1.1.0", optional = true)
},
description = "Adds fully custom legendary-like messages for tons of events, and optionally logs them, too.",
Expand Down Expand Up @@ -99,7 +99,7 @@ public class PixelmonBroadcasts
public static HashMap<UUID, Long> noticeExpiryMap = new HashMap<>();

// Create and set up config paths, and grab an OS-specific file path separator. This will usually be a forward slash.
private static String fileSystemSeparator = FileSystems.getDefault().getSeparator();
private static final String fileSystemSeparator = FileSystems.getDefault().getSeparator();
public static String configPathAsString = "config" + fileSystemSeparator + "PixelmonBroadcasts" + fileSystemSeparator;
public static Path broadcastsPath = Paths.get(configPathAsString, "broadcasts.conf");
public static Path messagesPath = Paths.get(configPathAsString, "messages.conf");
Expand All @@ -121,12 +121,12 @@ public class PixelmonBroadcasts
/* *\
Utility commands.
\* */
private static CommandSpec togglepreferences = CommandSpec.builder()
private static final CommandSpec togglepreferences = CommandSpec.builder()
.arguments(GenericArguments.optionalWeak(GenericArguments.string(Text.of("setting"))))
.executor(new Toggle())
.build();

private static CommandSpec reloadconfigs = CommandSpec.builder()
private static final CommandSpec reloadconfigs = CommandSpec.builder()
.permission("pixelmonbroadcasts.command.staff.reload")
.executor(new Reload())
.build();
Expand Down Expand Up @@ -225,35 +225,32 @@ public void onServerStartedEvent(final GameStartedServerEvent event)
// Complaining, commence.
logger.info("§f=============== P I X E L M O N B R O A D C A S T S ===============");
logger.info("§f--> §ePixelmon's \"§6displayLegendaryGlobalMessage§e\" setting is enabled.");
logger.info(" §eThis setting will now be disabled as it conflicts with this mod.");
logger.info(" §eIf you remove this mod, revert this in Pixelmon's config!");
logger.info(" §ePlease disable this setting, as it conflicts with this mod!");
logger.info("§f====================================================================");

// Flip the setting in Pixelmon's config.
// TODO: See if this can be made to work again in 8.0.0+.
/* // Flip the setting in Pixelmon's config.
PixelmonConfig.getConfig().getNode("Spawning", "displayLegendaryGlobalMessage").setValue(false);
PixelmonConfig.saveConfig();
// Force a config reload from disk.
try
{
PixelmonConfig.reload(true);
PixelmonConfig.reload();
}
catch (IOException F)
{
logger.info("");
logger.info("§cSomething went wrong during Pixelmon config reload from disk! Trace:");
F.printStackTrace();
}

if (configVersion != null && configVersion < 40)
logger.info("");
}*/
}

if (configVersion != null && configVersion < 40)
/*if (configVersion != null && configVersion < 40)
{
// More complaining, commence.
logger.info("§f=============== P I X E L M O N B R O A D C A S T S ===============");
logger.info("§f--> §eWelcome to the 0.4(.1) update! There's a bunch of new stuff.");
logger.info("§f--> §eWelcome to the 0.4(.2) update! There's a bunch of new stuff.");
logger.info(" §eDue to all of the changes, new configs are required. Sorry!");
logger.info("");
logger.info("§f--> §eTo finish updating, do the following:");
Expand All @@ -264,7 +261,7 @@ public void onServerStartedEvent(final GameStartedServerEvent event)
logger.info("§f====================================================================");
// TODO: Get this working without it squashing the whole config down.
/*// Set the config's version value to whatever version we're on right now.
// Set the config's version value to whatever version we're on right now.
try
{
settingsConfig.getNode("configVersion").setValue(40);
Expand All @@ -274,8 +271,8 @@ public void onServerStartedEvent(final GameStartedServerEvent event)
{
logger.error("Something broke while updating config version! Please report. Stack trace:");
F.printStackTrace();
}*/
}
}
}*/
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import rs.expand.pixelmonbroadcasts.enums.EventData;

import static rs.expand.pixelmonbroadcasts.PixelmonBroadcasts.logger;
import static rs.expand.pixelmonbroadcasts.utilities.PlaceholderMethods.getSafePlayer;
import static rs.expand.pixelmonbroadcasts.utilities.PlaceholderMethods.iterateAndBroadcast;
import static rs.expand.pixelmonbroadcasts.utilities.PrintingMethods.logEvent;
Expand All @@ -19,30 +20,36 @@ public void onPartyPokemonFaintEvent(PixelmonFaintEvent event)
{
if (!event.isCanceled())
{
// Make sure our Pokémon has an owner!
if (event.pokemon.hasOwner())
// Needed to work around a bug with Bide making this go null.
if (event.pokemon != null)
{
// Get a sanitized player, to work around a weird issue where "event.player" can go null.
final EntityPlayerMP player = getSafePlayer("EventData.Others.FAINT", event.player, event.pokemon);

// Did we get a player back? If not, things broke horribly.
if (player != null)
// Make sure our Pokémon has an owner!
if (event.pokemon.hasOwner())
{
// Create more shorthand variables for convenience.
final String baseName = event.pokemon.getPokemonName();
final String localizedName = event.pokemon.getLocalizedName();
// Get a sanitized player, to work around a weird issue where "event.player" can go null.
final EntityPlayerMP player = getSafePlayer("EventData.Others.FAINT", event.player, event.pokemon);

// Did we get a player back? If not, things broke horribly.
if (player != null)
{
// Create more shorthand variables for convenience.
final String baseName = event.pokemon.getPokemonName();
final String localizedName = event.pokemon.getLocalizedName();

// If we're in a localized setup, format a string for logging both names.
final String nameString = baseName.equals(localizedName) ? baseName : baseName + " (" + localizedName + ")";
// If we're in a localized setup, format a string for logging both names.
final String nameString = baseName.equals(localizedName) ? baseName : baseName + " (" + localizedName + ")";

// Send a log message if we're set up to do logging for this event.
logEvent(EventData.Others.FAINT, player.getEntityWorld().getWorldInfo().getWorldName(),
player.getPosition(), player.getName(), nameString);
// Send a log message if we're set up to do logging for this event.
logEvent(EventData.Others.FAINT, player.getEntityWorld().getWorldInfo().getWorldName(),
player.getPosition(), player.getName(), nameString);

// Send enabled broadcasts to people who should receive them.
iterateAndBroadcast(EventData.Others.FAINT, event.pokemon, null, player, null);
// Send enabled broadcasts to people who should receive them.
iterateAndBroadcast(EventData.Others.FAINT, event.pokemon, null, player, null);
}
}
}
else
logger.error("A fainting Pokémon event could not be parsed and was discarded! This is a Pixelmon bug.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.pixelmonmod.pixelmon.entities.pixelmon.stats.StatsType;
import com.pixelmonmod.pixelmon.enums.EnumGrowth;
import com.pixelmonmod.pixelmon.enums.EnumNature;
import com.pixelmonmod.pixelmon.enums.forms.EnumAlolan;
import com.pixelmonmod.pixelmon.enums.forms.RegionalForms;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
Expand Down Expand Up @@ -346,8 +346,10 @@ private static String getBroadcast(final String key, final Object object1, final
final String pokemonName;
if (pokemon.isEgg())
pokemonName = getTranslation("placeholder.pokemon.is_egg");
else if (pokemon.getFormEnum() == EnumAlolan.ALOLAN)
else if (pokemon.getFormEnum() == RegionalForms.ALOLAN)
pokemonName = "Alolan " + pokemon.getSpecies().getLocalizedName();
else if (pokemon.getFormEnum() == RegionalForms.GALARIAN)
pokemonName = "Galarian " + pokemon.getSpecies().getLocalizedName();
else
pokemonName = pokemon.getSpecies().getLocalizedName();

Expand Down Expand Up @@ -423,8 +425,10 @@ else if (pokemon.getFormEnum() == EnumAlolan.ALOLAN)
final String pokemon2Name;
if (pokemon2.isEgg())
pokemon2Name = getTranslation("placeholder.pokemon.is_egg");
else if (pokemon2.getFormEnum() == EnumAlolan.ALOLAN)
else if (pokemon2.getFormEnum() == RegionalForms.ALOLAN)
pokemon2Name = "Alolan " + pokemon2.getSpecies().getLocalizedName();
else if (pokemon2.getFormEnum() == RegionalForms.GALARIAN)
pokemon2Name = "Galarian " + pokemon2.getSpecies().getLocalizedName();
else
pokemon2Name = pokemon2.getSpecies().getLocalizedName();

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/broadcasts.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ------------------------------------------------------------------------------- #
# BROADCAST MESSAGE FILE, VERSION 0.4.1 (no changes since 0.4)
# BROADCAST MESSAGE FILE, VERSION 0.4.2 (no changes since 0.4)
#
# IMPORTANT:
# - Most messages support one or more placeholders from the list below.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/messages.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ------------------------------------------------------------------------------- #
# COMPONENT TRANSLATION FILE, VERSION 0.4.1 (moved hub no-perm keys to toggle)
# COMPONENT TRANSLATION FILE, VERSION 0.4.2 (no changes since 0.4.1)
#
# IMPORTANT:
# - Some messages have their own placeholders, marked {#} where # is a number.
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/settings.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ------------------------------------------------------------------------------- #
# MAIN CONFIGURATION FILE, VERSION 0.4.1 (no changes since 0.4)
# MAIN CONFIGURATION FILE, VERSION 0.4.2 (no changes since 0.4)
#
# SUPPORTED OPTIONS:
# - "log" = Log this event to the console and the server logs.
Expand All @@ -26,7 +26,7 @@
# # # CONFIG VERSION - DO NOT TOUCH UNLESS TOLD TO! # # #
# This is used internally to check for outdated (and possibly dangerous) configs.
# If needed, we show a warning on boot. The sidemod may be disabled until fixed.
configVersion = 41
configVersion = 42

# # # COMMAND ALIAS # # #
# A forward slash will automatically be added where necessary, don't add one.
Expand Down

0 comments on commit 84b6f8c

Please sign in to comment.