Skip to content

Commit

Permalink
add 'strong warning' system, bump several deprecations up
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 6, 2020
1 parent 90f7685 commit dfee73d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.denizenscript.denizencore.utilities.debugging.FutureWarning;
import com.denizenscript.denizencore.utilities.debugging.SlowWarning;
import com.denizenscript.denizencore.utilities.debugging.StrongWarning;
import com.denizenscript.denizencore.utilities.debugging.Warning;

/**
Expand All @@ -11,7 +12,7 @@
public class Deprecations {

// Prime candidate for removal - been strongly deprecated for a very long time (exact date is unclear, but many years).
public static Warning ancientDefs = new Warning("Ancient style definitions ('%def%') are deprecated. Please use modern definition syntax: '<[def]>'.");
public static Warning ancientDefs = new StrongWarning("Ancient style definitions ('%def%') are deprecated. Please use modern definition syntax: '<[def]>'.");

// In Bukkit impl, Added on 2018/12/23
// Bad candidate for functionality removal - a bit handy to use in "/ex", despite being clearly bad in standard scripts.
Expand All @@ -20,27 +21,27 @@ public class Deprecations {
// ==================== Tag shorthands ====================
// ====== All added on 2019/02/06 ======
// Note: context was most often used, and needs to remain longer than the others.
public static Warning contextShorthand = new SlowWarning("Short-named tags are hard to read. Please use 'context' instead of 'c' as a root tag.");
public static Warning entryShorthand = new SlowWarning("Short-named tags are hard to read. Please use 'entry' instead of 'e' as a root tag.");
public static Warning defShorthand = new Warning("Short-named tags are hard to read. Please use 'def' instead of 'd' as a root tag.");
public static Warning procShorthand = new Warning("Short-named tags are hard to read. Please use 'proc' instead of 'pr' as a root tag.");
public static Warning queueShorthand = new Warning("Short-named tags are hard to read. Please use 'queue' instead of 'q' as a root tag.");
public static Warning scriptShorthand = new Warning("Short-named tags are hard to read. Please use 'script' instead of 's' as a root tag.");
public static Warning ternShorthand = new SlowWarning("Short-named tags are hard to read. Please use 'tern' instead of 't' as a root tag.");
public static Warning utilShorthand = new Warning("Short-named tags are hard to read. Please use 'util' instead of 'u' as a root tag.");
public static Warning contextShorthand = new Warning("Short-named tags are hard to read. Please use 'context' instead of 'c' as a root tag.");
public static Warning entryShorthand = new Warning("Short-named tags are hard to read. Please use 'entry' instead of 'e' as a root tag.");
public static Warning defShorthand = new StrongWarning("Short-named tags are hard to read. Please use 'def' instead of 'd' as a root tag.");
public static Warning procShorthand = new StrongWarning("Short-named tags are hard to read. Please use 'proc' instead of 'pr' as a root tag.");
public static Warning queueShorthand = new StrongWarning("Short-named tags are hard to read. Please use 'queue' instead of 'q' as a root tag.");
public static Warning scriptShorthand = new StrongWarning("Short-named tags are hard to read. Please use 'script' instead of 's' as a root tag.");
public static Warning ternShorthand = new StrongWarning("Short-named tags are hard to read. Please use 'tern' instead of 't' as a root tag.");
public static Warning utilShorthand = new StrongWarning("Short-named tags are hard to read. Please use 'util' instead of 'u' as a root tag.");
// In Bukkit impl:
public static Warning locationShorthand = new Warning("Short-named tags are hard to read. Please use 'location' instead of 'l' as a root tag.");
public static Warning playerShorthand = new SlowWarning("Short-named tags are hard to read. Please use 'player' instead of 'pl' as a root tag.");
public static Warning serverShorthand = new Warning("Short-named tags are hard to read. Please use 'server' instead of 'svr' as a root tag.");
public static Warning schematicShorthand = new Warning("Short-named tags are hard to read. Please use 'schematic' instead of 'schem' as a root tag.");
public static Warning locationShorthand = new StrongWarning("Short-named tags are hard to read. Please use 'location' instead of 'l' as a root tag.");
public static Warning playerShorthand = new Warning("Short-named tags are hard to read. Please use 'player' instead of 'pl' as a root tag.");
public static Warning serverShorthand = new StrongWarning("Short-named tags are hard to read. Please use 'server' instead of 'svr' as a root tag.");
public static Warning schematicShorthand = new StrongWarning("Short-named tags are hard to read. Please use 'schematic' instead of 'schem' as a root tag.");
// ==================== End tag shorthands ====================

// In Bukkit impl, Added on 2019/02/06
public static Warning globalTagName = new Warning("Using 'global' as a base tag is a deprecated alternate name. Please use 'server' instead.");
public static Warning globalTagName = new StrongWarning("Using 'global' as a base tag is a deprecated alternate name. Please use 'server' instead.");

// In Bukkit impl, Added on 2019/03/08
// Prime candidate for functionality removal - has been unsupported for a LONG time.
public static Warning boundWarning = new Warning("Item script 'bound' functionality has never been reliable and should not be used. Consider replicating the concept with world events.");
public static Warning boundWarning = new StrongWarning("Item script 'bound' functionality has never been reliable and should not be used. Consider replicating the concept with world events.");

// Added on 2019/07/13
public static Warning oldEscapeTags = new SlowWarning("'escape:' tags are deprecated. Please use '.escaped' element tags instead.");
Expand All @@ -56,35 +57,35 @@ public class Deprecations {

// Added on 2019/08/27
// Prime candidate for functionality removal - hasn't been useful for several years.
public static Warning yamlFixFormatting = new SlowWarning("YAML command 'fix_formatting' argument is deprecated: this should never be used.");
public static Warning yamlFixFormatting = new Warning("YAML command 'fix_formatting' argument is deprecated: this should never be used.");

// Added on 2019/09/13
// Bad candidate for functionality removal - used to be commonly used
public static Warning elementAsInTag = new SlowWarning("'element.as_int' tag is deprecated: use '.round', '.round_down', '.round_up', or '.truncate'.");

// In Bukkit impl, Added on 2019/09/18, but was deprecated earlier.
public static Warning worldContext = new SlowWarning("'context.world' in events containing a location or chunk context is deprecated: use 'context.location.world' or similar to get the world value.");
public static Warning entityBreaksHangingEventContext = new SlowWarning("'context.entity' in event 'on player breaks hanging' is deprecated: use 'context.breaker'.");
public static Warning hangingBreaksEventContext = new SlowWarning("'context.location' in event 'on hanging breaks' is deprecated: use 'context.hanging.location'.");
public static Warning worldContext = new Warning("'context.world' in events containing a location or chunk context is deprecated: use 'context.location.world' or similar to get the world value.");
public static Warning entityBreaksHangingEventContext = new Warning("'context.entity' in event 'on player breaks hanging' is deprecated: use 'context.breaker'.");
public static Warning hangingBreaksEventContext = new Warning("'context.location' in event 'on hanging breaks' is deprecated: use 'context.hanging.location'.");
public static Warning playerRightClicksEntityContext = new SlowWarning("'context.location' in event 'on player right clicks entity' is deprecated: use 'context.entity.location'.");
public static Warning blockDispensesItemDetermination = new SlowWarning("Multiplier double determination for 'on block dispenses item' is deprecated: use 'context.velocity.mul[#]'.");
public static Warning serverRedirectLogging = new SlowWarning("server mechanism redirect_logging is deprecated: use the system mechanism by the same name.");
public static Warning blockDispensesItemDetermination = new Warning("Multiplier double determination for 'on block dispenses item' is deprecated: use 'context.velocity.mul[#]'.");
public static Warning serverRedirectLogging = new Warning("server mechanism redirect_logging is deprecated: use the system mechanism by the same name.");

// In Bukkit impl, Added on 2019/09/25, but was deprecated earlier.
public static Warning qtyTags = new SlowWarning("'qty' in a tag is deprecated: use 'quantity'.");
public static Warning playerStepTag = new SlowWarning("'player.current_step[script]' tag is deprecated: use 'script.step[player]'.");
public static Warning playerGamemodeTag = new SlowWarning("player.gamemode.id tag is deprecated: IDs are no longer in use. Use the player.gamemode (named) tag.");
public static Warning playerStepTag = new Warning("'player.current_step[script]' tag is deprecated: use 'script.step[player]'.");
public static Warning playerGamemodeTag = new Warning("player.gamemode.id tag is deprecated: IDs are no longer in use. Use the player.gamemode (named) tag.");

// In Bukkit impl, Added on 2019/09/25.
// Prime candidate for functionality removal - tags were only recently added, and were always jank.
public static Warning bookItemRawTags = new SlowWarning("Raw text tags for books were a placeholder. The normal (non-raw) tags now contain all needed data.");
public static Warning bookItemRawTags = new Warning("Raw text tags for books were a placeholder. The normal (non-raw) tags now contain all needed data.");

// In Bukkit impl, Added on 2019/10/13
// This is just a message, relevant functionality already removed. Remove the script container registration after a few releases.
public static Warning versionScripts = new SlowWarning("Version script containers are deprecated due to the old script repo no longer being active.");

// Added on 2019/10/13
public static Warning scriptReloadEventNoUnderscore = new SlowWarning("In the 'on script reload' event, 'had_error' should be used instead of 'haderror'.");
public static Warning scriptReloadEventNoUnderscore = new Warning("In the 'on script reload' event, 'had_error' should be used instead of 'haderror'.");

// In Bukkit impl, Added on 2019/11/22
public static Warning serverPluginNamesTag = new SlowWarning("'server.list_plugin_names' is deprecated: use 'server.list_plugins'");
Expand All @@ -102,35 +103,34 @@ public class Deprecations {
// In Bukkit impl, Added on 2019/12/24
public static Warning entityRemainingAir = new SlowWarning("The mechanism 'EntityTag.remaining_air' is deprecated: use 'EntityTag.oxygen' instead (duration input vs. tick input).");

// ==================== SPECIAL deprecations: Minecraft version ====================

// In Bukit impl, To be removed when Minecraft 1.12.2 is no longer supported by the Bukkit impl:
public static Warning materialIds = new Warning("Material ID and data magic number support is deprecated and WILL be removed in a future release.");
public static Warning materialIdsSuggestProperties = new Warning("Material ID and data magic number support is deprecated and WILL be removed in a future release. Use relevant properties instead.");
public static Warning materialIdsSuggestNames = new Warning("Material ID and data magic number support is deprecated and WILL be removed in a future release. Use material names instead.");
public static Warning skullSkinMaterials = new Warning("As of Minecraft version 1.13 you may only set the skin of a PLAYER_HEAD or PLAYER_WALL_HEAD.");
public static Warning flowerpotMechanism = new Warning("As of Minecraft version 1.13 potted flowers each have their own material, such as POTTED_CACTUS.");

// ==================== FUTURE deprecations ====================

// In Bukkit impl, Relevant as of 2019/07/13, deprecate officially by 2020.
public static Warning oldParseTag = new FutureWarning("'parse:' tags are deprecated. Please use '.parsed' element tags instead.");
public static Warning oldParseTag = new SlowWarning("'parse:' tags are deprecated. Please use '.parsed' element tags instead.");

// Added on 2019/10/09, but was changed earlier, deprecate officially by 2020.
public static Warning oldTernTag = new FutureWarning("'tern[a]:b||c' tag style is deprecated. Please use 'tern[a].pass[b].fail[c]' tag style instead.");
public static Warning oldTernTag = new SlowWarning("'tern[a]:b||c' tag style is deprecated. Please use 'tern[a].pass[b].fail[c]' tag style instead.");

// In Bukkit impl, Relevant as of 2019/09/09, deprecate officially by 2020.
public static Warning oldNPCNavigator = new FutureWarning("'npc.navigator.*' tags are deprecated. Just remove the '.navigator' part, they're the same after that.");
public static Warning oldNPCNavigator = new SlowWarning("'npc.navigator.*' tags are deprecated. Just remove the '.navigator' part, they're the same after that.");

// Relevant as of 2019/09/13, deprecate officially by 2020.
public static Warning oldMatchesOperator = new FutureWarning("'matches', 'is_empty', and 'contains' operators are deprecated. Use the logically equivalent tags instead.");
public static Warning oldMatchesOperator = new SlowWarning("'matches', 'is_empty', and 'contains' operators are deprecated. Use the logically equivalent tags instead.");

// In Bukkit impl, Relevant as of 2019/09/24, deprecate officially by 2020.
public static Warning oldRecipeScript = new FutureWarning("Item script single-recipe format is outdated. Use the modern 'recipes' list key (see meta docs).");
public static Warning oldRecipeScript = new SlowWarning("Item script single-recipe format is outdated. Use the modern 'recipes' list key (see meta docs).");

// Added 2019/11/11, deprecate officially by 2020.
public static Warning oldTagTickSyntax = new FutureWarning("The '^' prefix syntax for 'instant' tags is outdated. Please instead use the 'define' command to track the original player/NPC.");
public static Warning oldTagTickSyntax = new SlowWarning("The '^' prefix syntax for 'instant' tags is outdated. Please instead use the 'define' command to track the original player/NPC.");

// ==================== SPECIAL deprecations: Minecraft version ====================

// In Bukit impl, To be removed when Minecraft 1.12.2 is no longer supported by the Bukkit impl:
public static Warning materialIds = new Warning("Material ID and data magic number support is deprecated and WILL be removed in a future release.");
public static Warning materialIdsSuggestProperties = new Warning("Material ID and data magic number support is deprecated and WILL be removed in a future release. Use relevant properties instead.");
public static Warning materialIdsSuggestNames = new Warning("Material ID and data magic number support is deprecated and WILL be removed in a future release. Use material names instead.");
public static Warning skullSkinMaterials = new Warning("As of Minecraft version 1.13 you may only set the skin of a PLAYER_HEAD or PLAYER_WALL_HEAD.");
public static Warning flowerpotMechanism = new Warning("As of Minecraft version 1.13 potted flowers each have their own material, such as POTTED_CACTUS.");

// ==================== FUTURE deprecations ====================
// In Bukkit impl, Relevant as of 2019/09/25, deprecate officially by 2021.
private static String pointlessSubtagPrefix = "Most pointless sub-tags are deprecated in favor of explicit unique tags. ";
public static Warning npcNicknameTag = new FutureWarning(pointlessSubtagPrefix + "npc.name.nickname is now just npc.nickname.");
Expand All @@ -148,7 +148,7 @@ public class Deprecations {
public static Warning entityMaxOxygenTag = new FutureWarning(pointlessSubtagPrefix + "entity.oxygen.max is now just entity.max_oxygen.");
public static Warning itemBookTags = new FutureWarning(pointlessSubtagPrefix + "item.book.* tags are now just item.book_*.");

// In Bukkit impl, Added 2019/11/11 deprecate officially by 2021.
// In Bukkit impl, Added 2019/11/11, deprecate officially by 2021.
public static Warning entityLocationCursorOnTag = new FutureWarning("entity.location.cursor_on tags should be replaced by entity.cursor_on (be careful with the slight differences though).");

// In Bukkit impl, Added 2019/10/03, deprecate officially by 2021.
Expand All @@ -157,6 +157,6 @@ public class Deprecations {
// Added 2019/10/08, deprecate officially by 2021.
public static Warning ifCommandSingleLine = new FutureWarning("Single line if commands are deprecated. Please update them to modern format.");

// Added 2019/10/08, deprecate officially by 2022.
// Added 2019/10/08, but unoffically deprecated earlier, deprecate officially by 2022.
public static Warning oldBraceSyntax = new FutureWarning("The { braced } command format is deprecated. Please use the ':' colon syntax (refer to documentation).");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.denizenscript.denizencore.utilities.debugging;

import java.util.HashSet;

public class StrongWarning extends Warning {

public static HashSet<StrongWarning> recentWarnings = new HashSet<>();

public StrongWarning(String message) {
super(message);
}

@Override
public boolean testShouldWarn() {
recentWarnings.add(this);
return true;
}
}

0 comments on commit dfee73d

Please sign in to comment.