浏览代码

Changed Spout notification tiers to be stored in SpoutConfig instead of
AdvancedConfig. Also restructured some Spout stuff for easier
readability.

GJ 12 年之前
父节点
当前提交
fd675ac291

+ 1 - 0
Changelog.txt

@@ -44,6 +44,7 @@ Version 1.4.06-dev
  = Fixed bug with removing players from mySQL database
  = Fixed bug with empty metadata lists and Smelting
  = Fixed bug where Blast Mining would drop wrong items
+ ! Changed Spout notification tiers to be stored in SpoutConfig instead of AdvancedConfig
  ! Changed Berserk to add items to inventory rather than denying pickup
  ! Changed Call of the Wild, newly summoned pet's will have a custom name. (added permission node to disable this)
  ! Changed Chimaera Wing's recipe result to use the ingredient Material

+ 0 - 6
src/main/java/com/gmail/nossr50/config/AdvancedConfig.java

@@ -277,12 +277,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
     public double getWoodcuttingDoubleDropChance() { return config.getDouble("Skills.Woodcutting.DoubleDrops_ChanceMax", 100.0D); }
     public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
 
-    /* SPOUT STUFF*/
-    public int getSpoutNotificationTier1() { return config.getInt("Spout.Notifications.Tier1", 200); }
-    public int getSpoutNotificationTier2() { return config.getInt("Spout.Notifications.Tier2", 400); }
-    public int getSpoutNotificationTier3() { return config.getInt("Spout.Notifications.Tier3", 600); }
-    public int getSpoutNotificationTier4() { return config.getInt("Spout.Notifications.Tier4", 800); }
-
     /* KRAKEN STUFF */
     public boolean getKrakenEnabled() { return config.getBoolean("Kraken.Enabled", true); }
     public boolean getKrakenGlobalSoundsEnabled() { return config.getBoolean("Kraken.Global_Sounds", true); }

+ 6 - 0
src/main/java/com/gmail/nossr50/config/spout/SpoutConfig.java

@@ -66,4 +66,10 @@ public class SpoutConfig extends ConfigLoader {
     public double getRetroHUDRed(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
     public double getRetroHUDGreen(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
     public double getRetroHUDBlue(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
+
+    /* Notification Tiers */
+    public int getNotificationTier1() { return config.getInt("Notifications.Tier1", 200); }
+    public int getNotificationTier2() { return config.getInt("Notifications.Tier2", 400); }
+    public int getNotificationTier3() { return config.getInt("Notifications.Tier3", 600); }
+    public int getNotificationTier4() { return config.getInt("Notifications.Tier4", 800); }
 }

+ 208 - 277
src/main/java/com/gmail/nossr50/util/spout/SpoutUtils.java

@@ -11,12 +11,13 @@ import java.util.jar.JarFile;
 
 import org.bukkit.Material;
 import org.bukkit.entity.Player;
+import org.bukkit.plugin.PluginManager;
 import org.getspout.spoutapi.SpoutManager;
 import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
 import org.getspout.spoutapi.player.SpoutPlayer;
 
 import com.gmail.nossr50.mcMMO;
-import com.gmail.nossr50.config.AdvancedConfig;
+import com.gmail.nossr50.config.spout.SpoutConfig;
 import com.gmail.nossr50.datatypes.player.PlayerProfile;
 import com.gmail.nossr50.datatypes.skills.SkillType;
 import com.gmail.nossr50.locale.LocaleLoader;
@@ -25,11 +26,90 @@ import com.gmail.nossr50.util.player.UserManager;
 import com.gmail.nossr50.util.skills.SkillUtils;
 
 public class SpoutUtils {
-    public final static String spoutDirectory = mcMMO.getMainDirectory() + "Resources" + File.separator;
-    public final static String hudDirectory = spoutDirectory + "HUD" + File.separator;
-    public final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator;
-    public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator;
-    public final static String soundDirectory = spoutDirectory + "Sound" + File.separator;
+    // The order of the values is extremely important, a few methods depend on it to work properly
+    protected enum Tier {
+        FOUR(4) {
+            @Override public int getLevel() { return SpoutConfig.getInstance().getNotificationTier4(); }
+            @Override protected Material getAcrobaticsNotificationItem() { return Material.DIAMOND_BOOTS; }
+            @Override protected Material getArcheryNotificationItem() { return Material.BOW; }
+            @Override protected Material getAxesNotificationItem() { return Material.DIAMOND_AXE; }
+            @Override protected Material getExcavationNotificationItem() { return Material.CLAY; }
+            @Override protected Material getFishingNotificationItem() { return Material.FISHING_ROD; }
+            @Override protected Material getHerbalismNotificationItem() { return Material.WATER_LILY; }
+            @Override protected Material getMiningNotificationItem() { return Material.EMERALD_ORE; }
+            @Override protected Material getSwordsNotificationItem() { return Material.DIAMOND_SWORD; }
+            @Override protected Material getTamingNotificationItem() { return Material.BONE; }
+            @Override protected Material getUnarmedNotificationItem() { return Material.DIAMOND_HELMET; }
+            @Override protected Material getWoodcuttingNotificationItem() { return Material.LOG; }},
+        THREE(3) {
+            @Override public int getLevel() { return SpoutConfig.getInstance().getNotificationTier3(); }
+            @Override protected Material getAcrobaticsNotificationItem() { return Material.GOLD_BOOTS; }
+            @Override protected Material getArcheryNotificationItem() { return Material.ARROW; }
+            @Override protected Material getAxesNotificationItem() { return Material.GOLD_AXE; }
+            @Override protected Material getExcavationNotificationItem() { return Material.SAND; }
+            @Override protected Material getFishingNotificationItem() { return Material.COOKED_FISH; }
+            @Override protected Material getHerbalismNotificationItem() { return Material.RED_ROSE; }
+            @Override protected Material getMiningNotificationItem() { return Material.DIAMOND_ORE; }
+            @Override protected Material getSwordsNotificationItem() { return Material.GOLD_SWORD; }
+            @Override protected Material getTamingNotificationItem() { return Material.GRILLED_PORK; }
+            @Override protected Material getUnarmedNotificationItem() { return Material.GOLD_HELMET; }
+            @Override protected Material getWoodcuttingNotificationItem() { return Material.WOOD; }},
+        TWO(2) {
+            @Override public int getLevel() { return SpoutConfig.getInstance().getNotificationTier2(); }
+            @Override protected Material getAcrobaticsNotificationItem() { return Material.IRON_BOOTS; }
+            @Override protected Material getArcheryNotificationItem() { return Material.ARROW; }
+            @Override protected Material getAxesNotificationItem() { return Material.IRON_AXE; }
+            @Override protected Material getExcavationNotificationItem() { return Material.GRAVEL; }
+            @Override protected Material getFishingNotificationItem() { return Material.COOKED_FISH; }
+            @Override protected Material getHerbalismNotificationItem() { return Material.YELLOW_FLOWER; }
+            @Override protected Material getMiningNotificationItem() { return Material.GOLD_ORE; }
+            @Override protected Material getSwordsNotificationItem() { return Material.IRON_SWORD; }
+            @Override protected Material getTamingNotificationItem() { return Material.GRILLED_PORK; }
+            @Override protected Material getUnarmedNotificationItem() { return Material.IRON_HELMET; }
+            @Override protected Material getWoodcuttingNotificationItem() { return Material.LEAVES; }},
+        ONE(1) {
+            @Override public int getLevel() { return SpoutConfig.getInstance().getNotificationTier1(); }
+            @Override protected Material getAcrobaticsNotificationItem() { return Material.CHAINMAIL_BOOTS; }
+            @Override protected Material getArcheryNotificationItem() { return Material.FLINT; }
+            @Override protected Material getAxesNotificationItem() { return Material.STONE_AXE; }
+            @Override protected Material getExcavationNotificationItem() { return Material.GRASS; }
+            @Override protected Material getFishingNotificationItem() { return Material.RAW_FISH; }
+            @Override protected Material getHerbalismNotificationItem() { return Material.CACTUS; }
+            @Override protected Material getMiningNotificationItem() { return Material.IRON_ORE; }
+            @Override protected Material getSwordsNotificationItem() { return Material.STONE_SWORD; }
+            @Override protected Material getTamingNotificationItem() { return Material.PORK; }
+            @Override protected Material getUnarmedNotificationItem() { return Material.CHAINMAIL_HELMET; }
+            @Override protected Material getWoodcuttingNotificationItem() { return Material.SAPLING; }};
+
+        int numerical;
+
+        private Tier(int numerical) {
+            this.numerical = numerical;
+        }
+
+        public int toNumerical() {
+            return numerical;
+        }
+
+        abstract protected int getLevel();
+        abstract protected Material getAcrobaticsNotificationItem();
+        abstract protected Material getArcheryNotificationItem();
+        abstract protected Material getAxesNotificationItem();
+        abstract protected Material getExcavationNotificationItem();
+        abstract protected Material getFishingNotificationItem();
+        abstract protected Material getHerbalismNotificationItem();
+        abstract protected Material getMiningNotificationItem();
+        abstract protected Material getSwordsNotificationItem();
+        abstract protected Material getTamingNotificationItem();
+        abstract protected Material getUnarmedNotificationItem();
+        abstract protected Material getWoodcuttingNotificationItem();
+    }
+
+    private final static String spoutDirectory = mcMMO.getMainDirectory() + "Resources" + File.separator;
+    private final static String hudDirectory = spoutDirectory + "HUD" + File.separator;
+    private final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator;
+    private final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator;
+    private final static String soundDirectory = spoutDirectory + "Sound" + File.separator;
 
     /**
      * Write file to disk.
@@ -188,334 +268,185 @@ public class SpoutUtils {
      */
     public static void levelUpNotification(SkillType skillType, SpoutPlayer spoutPlayer) {
         PlayerProfile profile = UserManager.getPlayer(spoutPlayer).getProfile();
-        int notificationTier = getNotificationTier(profile.getSkillLevel(skillType));
-        Material mat = null;
+        int skillLevel = profile.getSkillLevel(skillType);
+        Material notificationItem;
 
         switch (skillType) {
-            case TAMING:
-                switch (notificationTier) {
-                    case 1:
-                    case 2:
-                        mat = Material.PORK;
-                        break;
-
-                    case 3:
-                    case 4:
-                        mat = Material.GRILLED_PORK;
-                        break;
-
-                    case 5:
-                        mat = Material.BONE;
-                        break;
-
-                    default:
-                        break;
-                }
-
+            case ACROBATICS:
+                notificationItem = getAcrobaticsNotificationItem(skillLevel);
                 break;
 
-            case MINING:
-                switch (notificationTier) {
-                    case 1:
-                        mat = Material.COAL_ORE;
-                        break;
-
-                    case 2:
-                        mat = Material.IRON_ORE;
-                        break;
-
-                    case 3:
-                        mat = Material.GOLD_ORE;
-                        break;
-
-                    case 4:
-                        mat = Material.DIAMOND_ORE;
-                        break;
-
-                    case 5:
-                        mat = Material.EMERALD_ORE;
-                        break;
-
-                    default:
-                        break;
-                }
-
+            case ARCHERY:
+                notificationItem = getArcheryNotificationItem(skillLevel);
                 break;
 
-            case WOODCUTTING:
-                switch (notificationTier) {
-                    case 1:
-                        mat = Material.STICK;
-                        break;
-
-                    case 2:
-                    case 3:
-                        mat = Material.WOOD;
-                        break;
-
-                    case 4:
-                    case 5:
-                        mat = Material.LOG;
-                        break;
-
-                    default:
-                        break;
-                }
+            case AXES:
+                notificationItem = getAxesNotificationItem(skillLevel);
+                break;
 
+            case EXCAVATION:
+                notificationItem = getExcavationNotificationItem(skillLevel);
                 break;
 
-            case REPAIR:
-                mat = Material.ANVIL;
+            case FISHING:
+                notificationItem = getFishingNotificationItem(skillLevel);
                 break;
 
             case HERBALISM:
-                switch (notificationTier) {
-                    case 1:
-                        mat = Material.YELLOW_FLOWER;
-                        break;
-
-                    case 2:
-                        mat = Material.RED_ROSE;
-                        break;
-
-                    case 3:
-                        mat = Material.BROWN_MUSHROOM;
-                        break;
-
-                    case 4:
-                        mat = Material.RED_MUSHROOM;
-                        break;
-
-                    case 5:
-                        mat = Material.PUMPKIN;
-                        break;
-
-                    default:
-                        break;
-                }
-
+                notificationItem = getHerbalismNotificationItem(skillLevel);
                 break;
 
-            case ACROBATICS:
-                switch (notificationTier) {
-                    case 1:
-                        mat = Material.LEATHER_BOOTS;
-                        break;
-
-                    case 2:
-                        mat = Material.CHAINMAIL_BOOTS;
-                        break;
-
-                    case 3:
-                        mat = Material.IRON_BOOTS;
-                        break;
-
-                    case 4:
-                        mat = Material.GOLD_BOOTS;
-                        break;
-
-                    case 5:
-                        mat = Material.DIAMOND_BOOTS;
-                        break;
-
-                    default:
-                        break;
-                }
+            case MINING:
+                notificationItem = getMiningNotificationItem(skillLevel);
+                break;
 
+            case REPAIR:
+                notificationItem = Material.ANVIL;
                 break;
 
             case SWORDS:
-                switch (notificationTier) {
-                    case 1:
-                        mat = Material.WOOD_SWORD;
-                        break;
-
-                    case 2:
-                        mat = Material.STONE_SWORD;
-                        break;
-
-                    case 3:
-                        mat = Material.IRON_SWORD;
-                        break;
-
-                    case 4:
-                        mat = Material.GOLD_SWORD;
-                        break;
-
-                    case 5:
-                        mat = Material.DIAMOND_SWORD;
-                        break;
-
-                    default:
-                        break;
-                }
-
+                notificationItem = getSwordsNotificationItem(skillLevel);
                 break;
 
-            case ARCHERY:
-                switch (notificationTier) {
-                    case 1:
-                    case 2:
-                    case 3:
-                        mat = Material.ARROW;
-                        break;
-
-                    case 4:
-                    case 5:
-                        mat = Material.BOW;
-                        break;
-
-                    default:
-                        break;
-                }
-
+            case TAMING:
+                notificationItem = getTamingNotificationItem(skillLevel);
                 break;
 
             case UNARMED:
-                switch (notificationTier) {
-                    case 1:
-                        mat = Material.LEATHER_HELMET;
-                        break;
-
-                    case 2:
-                        mat = Material.CHAINMAIL_HELMET;
-                        break;
+                notificationItem = getUnarmedNotificationItem(skillLevel);
+                break;
 
-                    case 3:
-                        mat = Material.IRON_HELMET;
-                        break;
+            case WOODCUTTING:
+                notificationItem = getWoodcuttingNotificationItem(skillLevel);
+                break;
 
-                    case 4:
-                        mat = Material.GOLD_HELMET;
-                        break;
+            default:
+                notificationItem = Material.MAP;
+                break;
+        }
 
-                    case 5:
-                        mat = Material.DIAMOND_HELMET;
-                        break;
+        spoutPlayer.sendNotification(LocaleLoader.getString("Spout.LevelUp.1"), LocaleLoader.getString("Spout.LevelUp.2", SkillUtils.getSkillName(skillType), skillLevel), notificationItem);
+        SpoutManager.getSoundManager().playCustomSoundEffect(mcMMO.p, spoutPlayer, "level.wav", false);
+    }
 
-                    default:
-                        break;
-                }
+    private static Material getAcrobaticsNotificationItem(int skillLevel) {
+        for (Tier tier : Tier.values()) {
+            if (skillLevel >= tier.getLevel()) {
+                return tier.getAcrobaticsNotificationItem();
+            }
+        }
 
-                break;
+        return Material.LEATHER_BOOTS;
+    }
 
-            case EXCAVATION:
-                switch (notificationTier) {
-                    case 1:
-                        mat = Material.WOOD_SPADE;
-                        break;
+    private static Material getArcheryNotificationItem(int skillLevel) {
+        for (Tier tier : Tier.values()) {
+            if (skillLevel >= tier.getLevel()) {
+                return tier.getArcheryNotificationItem();
+            }
+        }
 
-                    case 2:
-                        mat = Material.STONE_SPADE;
-                        break;
+        return Material.FEATHER;
+    }
 
-                    case 3:
-                        mat = Material.IRON_SPADE;
-                        break;
+    private static Material getAxesNotificationItem(int skillLevel) {
+        for (Tier tier : Tier.values()) {
+            if (skillLevel >= tier.getLevel()) {
+                return tier.getAxesNotificationItem();
+            }
+        }
 
-                    case 4:
-                        mat = Material.GOLD_SPADE;
-                        break;
+        return Material.WOOD_AXE;
+    }
 
-                    case 5:
-                        mat = Material.DIAMOND_SPADE;
-                        break;
+    private static Material getExcavationNotificationItem(int skillLevel) {
+        for (Tier tier : Tier.values()) {
+            if (skillLevel >= tier.getLevel()) {
+                return tier.getExcavationNotificationItem();
+            }
+        }
 
-                    default:
-                        break;
-                }
+        return Material.DIRT;
+    }
 
-                break;
+    private static Material getFishingNotificationItem(int skillLevel) {
+        for (Tier tier : Tier.values()) {
+            if (skillLevel >= tier.getLevel()) {
+                return tier.getFishingNotificationItem();
+            }
+        }
 
-            case AXES:
-                switch (notificationTier) {
-                    case 1:
-                        mat = Material.WOOD_AXE;
-                        break;
+        return Material.RAW_FISH;
+    }
 
-                    case 2:
-                        mat = Material.STONE_AXE;
-                        break;
+    private static Material getHerbalismNotificationItem(int skillLevel) {
+        for (Tier tier : Tier.values()) {
+            if (skillLevel >= tier.getLevel()) {
+                return tier.getHerbalismNotificationItem();
+            }
+        }
 
-                    case 3:
-                        mat = Material.IRON_AXE;
-                        break;
+        return Material.VINE;
+    }
 
-                    case 4:
-                        mat = Material.GOLD_AXE;
-                        break;
+    private static Material getMiningNotificationItem(int skillLevel) {
+        for (Tier tier : Tier.values()) {
+            if (skillLevel >= tier.getLevel()) {
+                return tier.getMiningNotificationItem();
+            }
+        }
 
-                    case 5:
-                        mat = Material.DIAMOND_AXE;
-                        break;
+        return Material.COAL_ORE;
+    }
 
-                    default:
-                        break;
-                }
+    private static Material getSwordsNotificationItem(int skillLevel) {
+        for (Tier tier : Tier.values()) {
+            if (skillLevel >= tier.getLevel()) {
+                return tier.getSwordsNotificationItem();
+            }
+        }
 
-                break;
+        return Material.WOOD_SWORD;
+    }
 
-            case FISHING:
-                switch (notificationTier) {
-                    case 1:
-                    case 2:
-                        mat = Material.RAW_FISH;
-                        break;
-
-                    case 3:
-                    case 4:
-                        mat = Material.COOKED_FISH;
-                        break;
-
-                    case 5:
-                        mat = Material.FISHING_ROD;
-                        break;
-
-                    default:
-                        break;
-                }
+    private static Material getTamingNotificationItem(int skillLevel) {
+        for (Tier tier : Tier.values()) {
+            if (skillLevel >= tier.getLevel()) {
+                return tier.getTamingNotificationItem();
+            }
+        }
 
-                break;
+        return Material.PORK;
+    }
 
-            default:
-                mat = Material.WATCH;
-                break;
+    private static Material getUnarmedNotificationItem(int skillLevel) {
+        for (Tier tier : Tier.values()) {
+            if (skillLevel >= tier.getLevel()) {
+                return tier.getUnarmedNotificationItem();
+            }
         }
 
-        spoutPlayer.sendNotification(LocaleLoader.getString("Spout.LevelUp.1"), LocaleLoader.getString("Spout.LevelUp.2", SkillUtils.getSkillName(skillType), profile.getSkillLevel(skillType)), mat);
-        SpoutManager.getSoundManager().playCustomSoundEffect(mcMMO.p, spoutPlayer, "level.wav", false);
+        return Material.LEATHER_HELMET;
     }
 
-    /**
-     * Gets the notification tier of a skill.
-     *
-     * @param level The level of the skill
-     * @return the notification tier of the skill
-     */
-    private static int getNotificationTier(int level) {
-        if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier4()) {
-            return 5;
-        }
-        else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier3()) {
-            return 4;
-        }
-        else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier2()) {
-            return 3;
-        }
-        else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier1()) {
-            return 2;
-        }
-        else {
-            return 1;
+    private static Material getWoodcuttingNotificationItem(int skillLevel) {
+        for (Tier tier : Tier.values()) {
+            if (skillLevel >= tier.getLevel()) {
+                return tier.getWoodcuttingNotificationItem();
+            }
         }
+
+        return Material.STICK;
     }
 
     /**
      * Re-enable SpoutCraft for players after a /reload
      */
     public static void reloadSpoutPlayers() {
+        PluginManager pluginManager = mcMMO.p.getServer().getPluginManager();
+
         for (SpoutPlayer spoutPlayer : SpoutManager.getPlayerChunkMap().getOnlinePlayers()) {
-            mcMMO.p.getServer().getPluginManager().callEvent(new SpoutCraftEnableEvent(spoutPlayer));
+            pluginManager.callEvent(new SpoutCraftEnableEvent(spoutPlayer));
         }
     }
 

+ 0 - 9
src/main/resources/advanced.yml

@@ -406,15 +406,6 @@ Skills:
         # DoubleDrops_MaxBonusLevel: Level when the maximum chance of receiving double drops is reached
         DoubleDrops_ChanceMax: 100.0
         DoubleDrops_MaxBonusLevel: 1000
-Spout:
-    #
-    #  Settings for the Spout notifications, when a player reaches a higher tier, the image of the notification will change.
-    ###
-    Notifications:
-        Tier1: 200
-        Tier2: 400
-        Tier3: 600
-        Tier4: 800
 #
 #  Customize the kraken!
 ###

+ 5 - 0
src/main/resources/spout.yml

@@ -70,3 +70,8 @@ HUD:
                 BLUE: 0.75
                 GREEN: 0.3
                 RED: 0.3
+Notifications:
+    Tier1: 200
+    Tier2: 400
+    Tier3: 600
+    Tier4: 800