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
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ monumenta {
pluginProject(":scripted-quests")
paper(
"com.playmonumenta.scriptedquests.Plugin", BukkitPluginDescription.PluginLoadOrder.POSTWORLD, "1.18",
depends = listOf("CommandAPI"),
depends = listOf("CommandAPI", "MonumentaCommon"),
softDepends = listOf("dynmap", "MonumentaRedisSync", "ProtocolLib"),
apiJarVersion = "1.20.4-R0.1-SNAPSHOT",
action = {
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ junit = "5.8.1"
junit-platform = "1.8.1"
mockito-junit = "5.8.0"
mockbukkit = "3.9.0"
monumenta-common = "1.0.0"
redissync = "6.0.0"

[libraries]
Expand All @@ -29,6 +30,7 @@ jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.re
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit-platform" }
mockito = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito-junit" }
mockbukkit = { module = "com.github.seeseemelk:MockBukkit-v1.20", version.ref = "mockbukkit" }
monumenta-common = { module = "com.playmonumenta:monumenta-common", version.ref = "monumenta-common" }
redissync = { module = "com.playmonumenta:redissync", version.ref = "redissync" }

[bundles]
Expand Down
3 changes: 3 additions & 0 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import org.gradle.api.plugins.quality.Pmd

repositories {
mavenLocal()
maven("https://repo.mikeprimm.com")
}

dependencies {
implementation(libs.bundles.google.api)

compileOnly(libs.monumenta.common)
testRuntimeOnly(libs.monumenta.common)
compileOnly(libs.commandapi)
compileOnly(libs.nbtapi)
compileOnly(libs.brigadier)
Expand Down

This file was deleted.

21 changes: 8 additions & 13 deletions plugin/src/main/java/com/playmonumenta/scriptedquests/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@
import com.playmonumenta.scriptedquests.managers.ZonePropertyManager;
import com.playmonumenta.scriptedquests.protocollib.ProtocolLibIntegration;
import com.playmonumenta.scriptedquests.timers.CommandTimerManager;
import com.playmonumenta.scriptedquests.utils.MMLog;
import com.playmonumenta.scriptedquests.utils.MetadataUtils;
import com.playmonumenta.scriptedquests.utils.NmsUtils;
import com.playmonumenta.scriptedquests.zones.ZoneManager;
import com.playmonumenta.scriptedquests.zones.ZonePropertyGroupManager;
import java.io.File;
import java.util.Objects;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.SoundCategory;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -76,16 +75,14 @@ public class Plugin extends JavaPlugin {

public Random mRandom = new Random();
private @MonotonicNonNull ScheduleFunction mScheduledFunctionsManager;
private @MonotonicNonNull CustomLogger mLogger = null;
private SoundCategory mDefaultMusicSoundCategory = SoundCategory.RECORDS;

@Override
public void onLoad() {
if (mLogger == null) {
mLogger = new CustomLogger(super.getLogger(), Level.INFO);
}
MMLog.init(getName());
com.playmonumenta.common.MMLogPaper.registerCommand(MMLog.getLog());

NmsUtils.loadVersionAdapter(this.getServer().getClass(), getLogger());
NmsUtils.loadVersionAdapter(this.getServer().getClass());

/*
* CommandAPI commands which register directly and are usable in functions
Expand All @@ -100,7 +97,6 @@ public void onLoad() {
mTranslationsManager = new TranslationsManager(this, translationsConfig);
}

ChangeLogLevel.register();
FontUtilsDebug.register();
InteractNpc.register(this);
Clickable.register(this);
Expand Down Expand Up @@ -303,12 +299,11 @@ public static Plugin getInstance() {
return INSTANCE;
}

/** @deprecated Use {@link com.playmonumenta.scriptedquests.utils.MMLog} static methods instead. */
@Deprecated
@Override
public Logger getLogger() {
if (mLogger == null) {
mLogger = new CustomLogger(super.getLogger(), Level.INFO);
}
return mLogger;
public java.util.logging.Logger getLogger() {
return super.getLogger();
}

public SoundCategory getDefaultMusicSoundCategory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.playmonumenta.scriptedquests.Plugin;
import com.playmonumenta.scriptedquests.quests.QuestContext;
import com.playmonumenta.scriptedquests.quests.components.QuestComponent;
import com.playmonumenta.scriptedquests.utils.MMLog;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.HashSet;
Expand Down Expand Up @@ -59,7 +60,7 @@ private static void sendJson(Player player, JsonObject object) {
out.write(GSON.toJson(object));
player.sendPluginMessage(Plugin.getInstance(), Constants.API_CHANNEL_ID, stream.toByteArray());
} catch (Exception e) {
e.printStackTrace();
MMLog.warning("Failed to send plugin message to player", e);
}
}

Expand Down Expand Up @@ -105,7 +106,7 @@ public void onPluginMessageReceived(String s, Player player, byte[] bytes) {
break; // Silently ignore other type requests
}
} catch (Exception e) {
e.printStackTrace();
MMLog.warning("Failed to handle incoming plugin message from player", e);
}
}

Expand All @@ -119,7 +120,7 @@ public static boolean shouldSend(Player p) {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
mOverride = !mOverride;
Plugin.getInstance().getLogger().info("Should always send custom data to player: " + mOverride);
MMLog.info("Should always send custom data to player: " + mOverride);
return true;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.playmonumenta.redissync.LeaderboardAPI;
import com.playmonumenta.scriptedquests.utils.LeaderboardUtils;
import com.playmonumenta.scriptedquests.utils.LeaderboardUtils.LeaderboardEntry;
import com.playmonumenta.scriptedquests.utils.MMLog;
import dev.jorel.commandapi.CommandAPI;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
Expand Down Expand Up @@ -175,8 +176,7 @@ public static void leaderboard(Plugin plugin, Player player, String objective, b
Bukkit.getScheduler().runTask(plugin, () -> LeaderboardUtils.sendLeaderboard(player, displayName, entries, page,
"/leaderboard " + player.getName() + " " + objective + (descending ? " true" : " false")));
} catch (Exception ex) {
plugin.getLogger().severe("Failed to generate leaderboard: " + ex.getMessage());
ex.printStackTrace();
MMLog.severe("Failed to generate leaderboard", ex);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public void run() {
}
}
}
mPlugin.getLogger().fine("Preparing to run " + entry);
MMLog.debug("Preparing to run " + entry);
it.remove();
}

Expand All @@ -229,8 +229,7 @@ public ScheduleFunction(Plugin plugin) {
try {
CommandAPI.unregister("schedule");
} catch (Exception e) {
// Nothing to do here - there is nothing to unregister in 1.13
plugin.getLogger().info("Failed to unregister /schedule - this is only an error in 1.14+");
MMLog.severe("Failed to unregister /schedule", e);
}

FunctionArgument functionArg = new FunctionArgument("function");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ protected void inventoryClose(InventoryCloseEvent event) {
try {
GuiPage updated = page.createUpdated(getInventory());
mGui.setPage(mPageName, updated);
QuestUtils.save(Plugin.getInstance(), event.getPlayer(), mGui.toJson(), mGui.getFile());
QuestUtils.save(event.getPlayer(), mGui.toJson(), mGui.getFile());
event.getPlayer().sendMessage(Component.text("GUI updated.", NamedTextColor.GOLD));
} catch (Exception e) {
event.getPlayer().sendMessage(Component.text("Failed to update GUI.", NamedTextColor.RED));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ protected void inventoryClick(InventoryClickEvent event) {
@Override
protected void inventoryClose(InventoryCloseEvent event) {
try {
QuestUtils.save(Plugin.getInstance(), event.getPlayer(), mTrader.toJson(), mTrader.getFile());
QuestUtils.save(event.getPlayer(), mTrader.toJson(), mTrader.getFile());
event.getPlayer().sendMessage(Component.text("Trade file updated.", NamedTextColor.GOLD));
} catch (Exception e) {
event.getPlayer().sendMessage(Component.text("Failed to update trade file.", NamedTextColor.RED));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.playmonumenta.scriptedquests.Plugin;
import com.playmonumenta.scriptedquests.races.Race;
import com.playmonumenta.scriptedquests.races.RaceFactory;
import com.playmonumenta.scriptedquests.utils.MMLog;
import com.playmonumenta.scriptedquests.utils.QuestUtils;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -92,12 +93,12 @@ public void removeIfNotActive(Entity entity) {
try {
ownerId = UUID.fromString(tag.substring(ARMOR_STAND_ID_PREFIX_TAG.length()));
} catch (Exception e) {
mPlugin.getLogger().warning("Invalid Race ID tag on ring: " + tag);
MMLog.warning("Invalid Race ID tag on ring: " + tag);
}
}
}
if (ownerId != null && !isRacing(ownerId)) {
mPlugin.getLogger().fine("Removing stale race ring armor stand.");
MMLog.debug("Removing stale race ring armor stand.");
entity.remove();
}
}
Expand Down Expand Up @@ -211,8 +212,8 @@ public void removeRace(Player player) {

public void startRace(Player player, String raceLabel) {
if (mActiveRaces.containsKey(player.getUniqueId())) {
mPlugin.getLogger().severe("Attempted to start second race '" + raceLabel +
"' for player '" + player.getName() + "'");
MMLog.severe("Attempted to start second race '" + raceLabel +
"' for player '" + player.getName() + "'");
player.sendMessage(Component.text("You are already in a race!", NamedTextColor.RED));
return;
}
Expand All @@ -222,7 +223,7 @@ public void startRace(Player player, String raceLabel) {

RaceFactory raceFactory = mRaceFactories.get(raceLabel);
if (raceFactory == null) {
mPlugin.getLogger().severe("Attempted to start nonexistent race '" + raceLabel + "'");
MMLog.severe("Attempted to start nonexistent race '" + raceLabel + "'");
return;
}

Expand Down
Loading
Loading