This commit is contained in:
nossr50
2019-04-24 17:17:14 -07:00
18 changed files with 826 additions and 427 deletions

View File

@ -55,14 +55,13 @@ public abstract class ChatCommand implements TabExecutor {
return true;
case 1:
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
if (CommandUtils.shouldEnableToggle(args[0])) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
enableChatMode(UserManager.getPlayer(sender.getName()), sender);
return true;
@ -72,6 +71,9 @@ public abstract class ChatCommand implements TabExecutor {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
disableChatMode(UserManager.getPlayer(sender.getName()), sender);
return true;

View File

@ -76,6 +76,7 @@ public class ExperienceConfig extends ConfigValidated {
public static final String OCELOT = "Ocelot";
public static final String WOLF = "Wolf";
public static final String FEATHER_FALL_MULTIPLIER = "FeatherFall_Multiplier";
private static final String PISTONS = "Pistons";
//TODO: Should merge be false? Seems okay to leave it as true..
public ExperienceConfig() {
@ -192,6 +193,8 @@ public class ExperienceConfig extends ConfigValidated {
return getBooleanValue(EXPLOIT_FIX, ENDERMAN_ENDERMITE_FARMS);
}
public boolean isPistonExploitPrevented() { return getBooleanValue(EXPLOIT_FIX, PISTONS); }
/* public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); }*/
@ -366,7 +369,6 @@ public class ExperienceConfig extends ConfigValidated {
return BarStyle.SOLID;
}
/* Repair */
public double getRepairXPBase() {
return getDoubleValue(EXPERIENCE, REPAIR, BASE1);

View File

@ -3,12 +3,16 @@ package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -18,11 +22,15 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
public class Party {
private final LinkedHashMap<UUID, String> members = new LinkedHashMap<>();
private final List<Player> onlineMembers = new ArrayList<>();
private static final String ONLINE_PLAYER_PREFIX = "";
private static final String OFFLINE_PLAYER_PREFIX = "";
private PartyLeader leader;
private String name;
private String password;
@ -191,7 +199,6 @@ public class Party {
}
public int getXpToLevel() {
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
return mcMMO.getFormulaManager().getPartyCachedXpToLevel(level);
}
@ -319,36 +326,203 @@ public class Party {
return this.getMembers().keySet().contains(uuid);
}
/**
* Makes a formatted list of party members based on the perspective of a target player
* Players that are hidden will be shown as offline (formatted in the same way)
* Party leader will be formatted a specific way as well
* @param player target player to use as POV
* @return formatted list of party members from the POV of a player
*/
public String createMembersList(Player player) {
StringBuilder memberList = new StringBuilder();
for (Player otherPlayer : this.getVisibleMembers(player)) {
String memberName = otherPlayer.getName();
List<UUID> onlineMembers = members.keySet().stream()
.filter(x -> Bukkit.getOfflinePlayer(x).isOnline())
.collect(Collectors.toList());
if (this.getLeader().getUniqueId().equals(otherPlayer.getUniqueId())) {
memberList.append(ChatColor.GOLD);
List<UUID> offlineMembers = members.keySet().stream()
.filter(x -> !Bukkit.getOfflinePlayer(x).isOnline())
.collect(Collectors.toList());
if (otherPlayer == null) {
memberName = memberName.substring(0, 1) + ChatColor.GRAY + ChatColor.ITALIC + "" + memberName.substring(1);
}
}
else if (otherPlayer != null) {
memberList.append(ChatColor.WHITE);
}
else {
memberList.append(ChatColor.GRAY);
}
ArrayList<UUID> visiblePartyList = new ArrayList<>();
boolean isPartyLeaderOfflineOrHidden = false;
ArrayList<UUID> offlineOrHiddenPartyList = new ArrayList<>();
if (player.getName().equalsIgnoreCase(otherPlayer.getName())) {
memberList.append(ChatColor.ITALIC);
}
for(UUID onlineMember : onlineMembers)
{
Player onlinePlayer = Bukkit.getPlayer(onlineMember);
memberList.append(memberName).append(ChatColor.RESET).append(" ");
if(!isNotSamePerson(player.getUniqueId(), onlineMember) || player.canSee(onlinePlayer))
{
visiblePartyList.add(onlineMember);
} else {
//Party leader and cannot be seen by this player
if(isNotSamePerson(leader.getUniqueId(), player.getUniqueId()) && onlineMember == leader.getUniqueId())
isPartyLeaderOfflineOrHidden = true;
offlineOrHiddenPartyList.add(onlineMember);
}
}
if(offlineMembers.contains(leader.getUniqueId()))
isPartyLeaderOfflineOrHidden = true;
//Add all the actually offline members
offlineOrHiddenPartyList.addAll(offlineMembers);
/* BUILD THE PARTY LIST WITH FORMATTING */
String partyLeaderPrefix =
/*ChatColor.WHITE
+ "["
+*/ ChatColor.GOLD
+ ""
/*+ ChatColor.WHITE
+ "]"*/
+ ChatColor.RESET;
//First add the party leader
memberList.append(partyLeaderPrefix);
List<Player> nearbyPlayerList = getNearMembers(UserManager.getPlayer(player));
boolean useDisplayNames = Config.getInstance().getPartyDisplayNames();
if(isPartyLeaderOfflineOrHidden)
{
if(isNotSamePerson(player.getUniqueId(), leader.getUniqueId()))
applyOnlineAndRangeFormatting(memberList, false, false);
memberList.append(ChatColor.GRAY)
.append(leader.getPlayerName());
}
else {
if(isNotSamePerson(leader.getUniqueId(), player.getUniqueId()))
applyOnlineAndRangeFormatting(memberList, true, nearbyPlayerList.contains(Bukkit.getPlayer(leader.getUniqueId())));
if(useDisplayNames) {
memberList.append(leader.getPlayerName());
} else {
memberList.append(ChatColor.GOLD)
.append(Bukkit.getOfflinePlayer(leader.getUniqueId()));
}
}
//Space
memberList.append(" ");
//Now do online members
for(UUID onlinePlayerUUID : visiblePartyList)
{
if(onlinePlayerUUID == leader.getUniqueId())
continue;
if(isNotSamePerson(onlinePlayerUUID, player.getUniqueId()))
applyOnlineAndRangeFormatting(memberList, true, nearbyPlayerList.contains(Bukkit.getPlayer(onlinePlayerUUID)));
if(useDisplayNames)
{
memberList.append(Bukkit.getPlayer(onlinePlayerUUID).getDisplayName());
}
else
{
//Color allies green, players dark aqua
memberList.append(ChatColor.GREEN)
.append(Bukkit.getPlayer(onlinePlayerUUID).getName());
}
memberList.append(" ").append(ChatColor.RESET);
}
for(UUID offlineOrHiddenPlayer : offlineOrHiddenPartyList)
{
if(offlineOrHiddenPlayer == leader.getUniqueId())
continue;
applyOnlineAndRangeFormatting(memberList, false, false);
memberList.append(ChatColor.GRAY)
.append(Bukkit.getOfflinePlayer(offlineOrHiddenPlayer).getName())
.append(" ").append(ChatColor.RESET);
}
// for (Player otherPlayer : this.getVisibleMembers(player)) {
// String memberName = otherPlayer.getName();
//
// if (this.getLeader().getUniqueId().equals(otherPlayer.getUniqueId())) {
// memberList.append(ChatColor.GOLD);
//
// if (otherPlayer == null) {
// memberName = memberName.substring(0, 1) + ChatColor.GRAY + ChatColor.ITALIC + "" + memberName.substring(1);
// }
// }
// else if (otherPlayer != null) {
// memberList.append(ChatColor.WHITE);
// }
// else {
// memberList.append(ChatColor.GRAY);
// }
//
// if (player.getName().equalsIgnoreCase(otherPlayer.getName())) {
// memberList.append(ChatColor.ITALIC);
// }
//
// memberList.append(memberName).append(ChatColor.RESET).append(" ");
// }
return memberList.toString();
}
private boolean isNotSamePerson(UUID onlinePlayerUUID, UUID uniqueId) {
return onlinePlayerUUID != uniqueId;
}
private void applyOnlineAndRangeFormatting(StringBuilder stringBuilder, boolean isVisibleOrOnline, boolean isNear)
{
if(isVisibleOrOnline)
{
if(isNear)
{
stringBuilder.append(ChatColor.GREEN);
} else {
stringBuilder.append(ChatColor.GRAY);
}
// stringBuilder.append(ChatColor.BOLD);
stringBuilder.append(ONLINE_PLAYER_PREFIX);
} else {
stringBuilder.append(ChatColor.GRAY);
stringBuilder.append(OFFLINE_PLAYER_PREFIX);
}
stringBuilder.append(ChatColor.RESET);
}
/**
* Get the near party members.
*
* @param mcMMOPlayer The player to check
* @return the near party members
*/
public List<Player> getNearMembers(McMMOPlayer mcMMOPlayer) {
List<Player> nearMembers = new ArrayList<Player>();
Party party = mcMMOPlayer.getParty();
if (party != null) {
Player player = mcMMOPlayer.getPlayer();
double range = Config.getInstance().getPartyShareRange();
for (Player member : party.getOnlineMembers()) {
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
nearMembers.add(member);
}
}
}
return nearMembers;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {

View File

@ -910,7 +910,7 @@ public class McMMOPlayer {
}
setToolPreparationMode(tool, true);
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
new ToolLowerTask(this, tool).runTaskLater(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
}
}

View File

@ -5,13 +5,14 @@ import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
/**
* This event is sent for when mcMMO informs a player about various important information
*/
public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancellable {
public class McMMOPlayerNotificationEvent extends Event implements Cancellable {
private boolean isCancelled;
/*
* Messages can be sent to both places, as configured in advanced.yml
@ -27,7 +28,7 @@ public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancell
protected final NotificationType notificationType;
public McMMOPlayerNotificationEvent(Player who, NotificationType notificationType, TextComponent notificationTextComponent, ChatMessageType chatMessageType, boolean isMessageAlsoBeingSentToChat) {
super(who);
super(false);
this.notificationType = notificationType;
this.notificationTextComponent = notificationTextComponent;
this.chatMessageType = chatMessageType;

View File

@ -243,7 +243,7 @@ public class EntityListener implements Listener {
if(defender instanceof Player)
{
LivingEntity defLive = (LivingEntity) defender;
defLive.setHealth(defLive.getHealth() - event.getFinalDamage());
defLive.setHealth(Math.max(0, (defLive.getHealth() - event.getFinalDamage())));
event.setCancelled(true);
}

View File

@ -101,8 +101,8 @@ public class SelfListener implements Listener {
return;
}
final float rawXp = event.getRawXpGained();
if (rawXp < 0) {
if (event.getRawXpGained() <= 0) {
// Don't calculate for XP subtraction
return;
}
@ -111,6 +111,19 @@ public class SelfListener implements Listener {
return;
}
int earlyLevelBonusXPCap = mcMMO.isRetroModeEnabled() ? 50 : 5;
int earlyGameBonusXP = 0;
//Give some bonus XP for low levels
if(mcMMOPlayer.getSkillLevel(primarySkillType) < earlyLevelBonusXPCap)
{
earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05);
event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP);
}
final float rawXp = event.getRawXpGained();
float guaranteedMinimum = ExperienceConfig.getInstance().getDiminishedReturnsCap() * rawXp;
float modifiedThreshold = (float) (threshold / primarySkillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());

View File

@ -28,10 +28,7 @@ import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.skills.alchemy.Alchemy;
import com.gmail.nossr50.skills.repair.repairables.RepairableManager;
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager;
import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.LogFilter;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
@ -48,9 +45,13 @@ import org.bukkit.event.HandlerList;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
public class mcMMO extends JavaPlugin {
public static final String COMPATIBLE_SERVER_SOFTWARE = "Spigot, Paper";
@ -63,8 +64,7 @@ public class mcMMO extends JavaPlugin {
//private static ModManager modManager;
private static DatabaseManager databaseManager;
private static FormulaManager formulaManager;
/*private static HolidayManager holidayManager;*/
//private static UpgradeManager upgradeManager;
private static MaterialMapStore materialMapStore;
/* File Paths */
private static String mainDirectory;
@ -80,6 +80,9 @@ public class mcMMO extends JavaPlugin {
/* Plugin Checks */
private static boolean healthBarPluginEnabled;
// API checks
private static boolean serverAPIOutdated = false;
// XP Event Check
private boolean xpEventEnabled;
@ -146,38 +149,56 @@ public class mcMMO extends JavaPlugin {
databaseManager = DatabaseManagerFactory.getDatabaseManager();
registerEvents();
registerCoreSkills();
registerCustomRecipes();
//Check for the newer API and tell them what to do if its missing
checkForOutdatedAPI();
if(serverAPIOutdated)
{
Bukkit
.getScheduler()
.scheduleSyncRepeatingTask(this,
() -> getLogger().severe("You are running an outdated version of "+getServerSoftware()+", mcMMO will not work unless you update to a newer version!"),
20, 20*60*30);
if(getServerSoftware() == ServerSoftwareType.CRAFTBUKKIT)
{
Bukkit.getScheduler()
.scheduleSyncRepeatingTask(this,
() -> getLogger().severe("We have detected you are using incompatible server software, our best guess is that you are using CraftBukkit. mcMMO requires Spigot or Paper, if you are not using CraftBukkit, you will still need to update your custom server software before mcMMO will work."),
20, 20*60*30);
}
} else {
registerEvents();
registerCoreSkills();
registerCustomRecipes();
if(getConfigManager().getConfigParty().isPartySystemEnabled())
PartyManager.loadParties();
formulaManager = new FormulaManager();
/*holidayManager = new HolidayManager();*/
for (Player player : getServer().getOnlinePlayers()) {
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
for (Player player : getServer().getOnlinePlayers()) {
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
debug("Version " + getDescription().getVersion() + " is enabled!");
debug("Version " + getDescription().getVersion() + " is enabled!");
scheduleTasks();
CommandRegistrationManager.registerCommands();
scheduleTasks();
CommandRegistrationManager.registerCommands();
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
if (mcMMO.getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) {
Permissions.generateWorldTeleportPermissions();
}
//Populate Ranked Skill Maps (DO THIS LAST)
RankUtils.populateRanks();
//Populate Ranked Skill Maps (DO THIS LAST)
RankUtils.populateRanks();
}
//If anonymous statistics are enabled then use them
if(getConfigManager().getConfigMetrics().isAllowAnonymousUsageStatistics()) {
Metrics metrics;
metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SimplePie("version", () -> getDescription().getVersion()));
@ -206,49 +227,53 @@ public class mcMMO extends JavaPlugin {
//getServer().getPluginManager().disablePlugin(this);
}
/*if(isIncompatibleVersion(Bukkit.getVersion(), Bukkit.getBukkitVersion()))
{
getLogger().severe("mcMMO is not supported for your current server software and or Minecraft version");
if(isServerSoftwareIncompatible(Bukkit.getVersion()))
{
getLogger().severe("mcMMO does not recognize your server software as being compatible!");
getLogger().severe("Compatible Server Software: "+ COMPATIBLE_SERVER_SOFTWARE);
getLogger().severe("Incompatible Server Software: "+ INCOMPATIBLE_SERVER_SOFTWARE);
}
if(isServerMinecraftVersionIncompatible(Bukkit.getBukkitVersion()))
{
getLogger().severe("mcMMO does not recognize your Minecraft Version as being compatible!");
getLogger().severe("Compatible Minecraft Versions: "+ COMPATIBLE_MINECRAFT_VERSIONS);
getLogger().info("TIP: Paper and Spigot are extensions of CraftBukkit and are completely safe to upgrade to from CraftBukkit, please consider upgrading.");
}
}*/
//Init Material Maps
materialMapStore = new MaterialMapStore();
}
private boolean isIncompatibleVersion(String serverSoftwareString, String serverVersionString)
public static MaterialMapStore getMaterialMapStore() {
return materialMapStore;
}
private void checkForOutdatedAPI() {
try {
Class<?> checkForClass = Class.forName("org.bukkit.event.block.BlockDropItemEvent");
Method newerAPIMethod = checkForClass.getMethod("getItems");
Class<?> checkForClassBaseComponent = Class.forName("net.md_5.bungee.api.chat.BaseComponent");
} catch (ClassNotFoundException | NoSuchMethodException e) {
serverAPIOutdated = true;
String software = getServerSoftwareStr();
getLogger().severe("You are running an older version of " + software + " that is not compatible with mcMMO, update your server software!");
}
}
private enum ServerSoftwareType {
PAPER,
SPIGOT,
CRAFTBUKKIT
}
private ServerSoftwareType getServerSoftware()
{
if (isServerSoftwareIncompatible(serverSoftwareString))
return true;
if (isServerMinecraftVersionIncompatible(serverVersionString))
return true;
return false;
if(Bukkit.getVersion().toLowerCase().contains("paper"))
return ServerSoftwareType.PAPER;
else if(Bukkit.getVersion().toLowerCase().contains("spigot"))
return ServerSoftwareType.SPIGOT;
else
return ServerSoftwareType.CRAFTBUKKIT;
}
private boolean isServerMinecraftVersionIncompatible(String serverVersionString) {
if(!serverVersionString.contains("1.13.2"))
return true;
return false;
}
private boolean isServerSoftwareIncompatible(String serverSoftwareString) {
if(!serverSoftwareString.contains("paper") && !serverSoftwareString.contains("spigot"))
return true;
return false;
private String getServerSoftwareStr()
{
switch(getServerSoftware())
{
case PAPER:
return "Paper";
case SPIGOT:
return "Spigot";
default:
return "CraftBukkit";
}
}
@Override

View File

@ -16,16 +16,17 @@ import java.util.HashSet;
public final class BlockUtils {
private BlockUtils() {}
private BlockUtils() {
}
/**
* Mark a block for giving bonus drops, double drops are used if triple is false
*
* @param blockState target blockstate
* @param triple marks the block to give triple drops
* @param triple marks the block to give triple drops
*/
public static void markDropsAsBonus(BlockState blockState, boolean triple)
{
if(triple)
public static void markDropsAsBonus(BlockState blockState, boolean triple) {
if (triple)
blockState.setMetadata(mcMMO.tripleDrops, mcMMO.metadataValue);
else
blockState.setMetadata(mcMMO.doubleDrops, mcMMO.metadataValue);
@ -33,6 +34,7 @@ public final class BlockUtils {
/**
* Checks if a player successfully passed the double drop check
*
* @param blockState the blockstate
* @return true if the player succeeded in the check
*/
@ -49,8 +51,7 @@ public final class BlockUtils {
/**
* Checks to see if a given block awards XP.
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block awards XP, false otherwise
*/
public static boolean shouldBeWatched(BlockState blockState) {
@ -60,236 +61,30 @@ public final class BlockUtils {
/**
* Check if a given block should allow for the activation of abilities
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block should allow ability activation, false
* otherwise
* otherwise
*/
public static boolean canActivateAbilities(BlockState blockState) {
switch (blockState.getType()) {
case BLACK_BED:
case BLUE_BED:
case BROWN_BED:
case CYAN_BED:
case GRAY_BED:
case GREEN_BED:
case LIGHT_BLUE_BED:
case LIGHT_GRAY_BED:
case LIME_BED:
case MAGENTA_BED:
case ORANGE_BED:
case PINK_BED:
case PURPLE_BED:
case RED_BED:
case WHITE_BED:
case YELLOW_BED:
case BREWING_STAND :
case BOOKSHELF :
case CAKE:
case CHEST :
case DISPENSER :
case ENCHANTING_TABLE:
case ENDER_CHEST :
case OAK_FENCE_GATE:
case ACACIA_FENCE_GATE :
case DARK_OAK_FENCE_GATE :
case SPRUCE_FENCE_GATE :
case BIRCH_FENCE_GATE :
case JUNGLE_FENCE_GATE :
case FURNACE :
case JUKEBOX :
case LEVER :
case NOTE_BLOCK :
case STONE_BUTTON :
case OAK_BUTTON:
case BIRCH_BUTTON:
case ACACIA_BUTTON:
case DARK_OAK_BUTTON:
case JUNGLE_BUTTON:
case SPRUCE_BUTTON:
case ACACIA_TRAPDOOR:
case BIRCH_TRAPDOOR:
case DARK_OAK_TRAPDOOR:
case JUNGLE_TRAPDOOR:
case OAK_TRAPDOOR:
case SPRUCE_TRAPDOOR:
case WALL_SIGN :
case CRAFTING_TABLE:
case BEACON :
case ANVIL :
case DROPPER :
case HOPPER :
case TRAPPED_CHEST :
case IRON_DOOR :
case IRON_TRAPDOOR :
case OAK_DOOR:
case ACACIA_DOOR :
case SPRUCE_DOOR :
case BIRCH_DOOR :
case JUNGLE_DOOR :
case DARK_OAK_DOOR :
case OAK_FENCE:
case ACACIA_FENCE :
case DARK_OAK_FENCE :
case BIRCH_FENCE :
case JUNGLE_FENCE :
case SPRUCE_FENCE :
case ARMOR_STAND :
case BLACK_SHULKER_BOX :
case BLUE_SHULKER_BOX :
case BROWN_SHULKER_BOX :
case CYAN_SHULKER_BOX :
case GRAY_SHULKER_BOX :
case GREEN_SHULKER_BOX :
case LIGHT_BLUE_SHULKER_BOX :
case LIME_SHULKER_BOX :
case MAGENTA_SHULKER_BOX :
case ORANGE_SHULKER_BOX :
case PINK_SHULKER_BOX :
case PURPLE_SHULKER_BOX :
case RED_SHULKER_BOX :
case LIGHT_GRAY_SHULKER_BOX:
case WHITE_SHULKER_BOX :
case YELLOW_SHULKER_BOX :
return false;
default :
return !isMcMMOAnvil(blockState);
//return !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState);
}
return !mcMMO.getMaterialMapStore().isAbilityActivationBlackListed(blockState.getType());
}
/**
* Check if a given block should allow for the activation of tools
* Activating a tool is step 1 of a 2 step process for super ability activation
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block should allow ability activation, false
* otherwise
* otherwise
*/
public static boolean canActivateTools(BlockState blockState) {
switch (blockState.getType()) {
case BLACK_BED:
case BLUE_BED:
case BROWN_BED:
case CYAN_BED:
case GRAY_BED:
case GREEN_BED:
case LIGHT_BLUE_BED:
case LIGHT_GRAY_BED:
case LIME_BED:
case MAGENTA_BED:
case ORANGE_BED:
case PINK_BED:
case PURPLE_BED:
case RED_BED:
case WHITE_BED:
case YELLOW_BED:
case BREWING_STAND :
case BOOKSHELF :
case CAKE:
case CHEST :
case DISPENSER :
case ENCHANTING_TABLE:
case ENDER_CHEST :
case OAK_FENCE_GATE:
case ACACIA_FENCE_GATE :
case DARK_OAK_FENCE_GATE :
case SPRUCE_FENCE_GATE :
case BIRCH_FENCE_GATE :
case JUNGLE_FENCE_GATE :
case FURNACE :
case JUKEBOX :
case LEVER :
case NOTE_BLOCK :
case STONE_BUTTON :
case OAK_BUTTON:
case BIRCH_BUTTON:
case ACACIA_BUTTON:
case DARK_OAK_BUTTON:
case JUNGLE_BUTTON:
case SPRUCE_BUTTON:
case ACACIA_TRAPDOOR:
case BIRCH_TRAPDOOR:
case DARK_OAK_TRAPDOOR:
case JUNGLE_TRAPDOOR:
case OAK_TRAPDOOR:
case SPRUCE_TRAPDOOR:
case WALL_SIGN :
case CRAFTING_TABLE:
case BEACON :
case ANVIL :
case DROPPER :
case HOPPER :
case TRAPPED_CHEST :
case IRON_DOOR :
case IRON_TRAPDOOR :
case OAK_DOOR:
case ACACIA_DOOR :
case SPRUCE_DOOR :
case BIRCH_DOOR :
case JUNGLE_DOOR :
case DARK_OAK_DOOR :
case OAK_FENCE:
case ACACIA_FENCE :
case DARK_OAK_FENCE :
case BIRCH_FENCE :
case JUNGLE_FENCE :
case SPRUCE_FENCE :
case ARMOR_STAND :
case BLACK_SHULKER_BOX :
case BLUE_SHULKER_BOX :
case BROWN_SHULKER_BOX :
case CYAN_SHULKER_BOX :
case GRAY_SHULKER_BOX :
case GREEN_SHULKER_BOX :
case LIGHT_BLUE_SHULKER_BOX :
case LIME_SHULKER_BOX :
case MAGENTA_SHULKER_BOX :
case ORANGE_SHULKER_BOX :
case PINK_SHULKER_BOX :
case PURPLE_SHULKER_BOX :
case RED_SHULKER_BOX :
case LIGHT_GRAY_SHULKER_BOX:
case WHITE_SHULKER_BOX :
case YELLOW_SHULKER_BOX :
case STRIPPED_ACACIA_LOG:
case STRIPPED_ACACIA_WOOD:
case STRIPPED_BIRCH_LOG:
case STRIPPED_BIRCH_WOOD:
case STRIPPED_DARK_OAK_LOG:
case STRIPPED_DARK_OAK_WOOD:
case STRIPPED_JUNGLE_LOG:
case STRIPPED_JUNGLE_WOOD:
case STRIPPED_OAK_LOG:
case STRIPPED_OAK_WOOD:
case STRIPPED_SPRUCE_LOG:
case STRIPPED_SPRUCE_WOOD:
case ACACIA_LOG:
case ACACIA_WOOD:
case BIRCH_LOG:
case BIRCH_WOOD:
case DARK_OAK_LOG:
case DARK_OAK_WOOD:
case JUNGLE_LOG:
case JUNGLE_WOOD:
case OAK_LOG:
case OAK_WOOD:
case SPRUCE_LOG:
case SPRUCE_WOOD:
return false;
default :
return !isMcMMOAnvil(blockState); // && !mcMMO.getModManager().isCustomAbilityBlock(blockState);
}
return !mcMMO.getMaterialMapStore().isToolActivationBlackListed(blockState.getType());
}
/**
* Check if a given block is an ore
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block is an ore, false otherwise
*/
public static boolean isOre(BlockState blockState) {
@ -299,31 +94,17 @@ public final class BlockUtils {
/**
* Determine if a given block can be made mossy
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block can be made mossy, false otherwise
*/
public static boolean canMakeMossy(BlockState blockState) {
switch (blockState.getType()) {
case COBBLESTONE :
case DIRT :
case GRASS_PATH :
case COBBLESTONE_WALL:
case STONE_BRICKS:
return true;
default :
return false;
}
return mcMMO.getMaterialMapStore().isMossyWhiteListed(blockState.getType());
}
/**
* Determine if a given block should be affected by Green Terra
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block should affected by Green Terra, false otherwise
*/
public static boolean affectedByGreenTerra(BlockState blockState) {
@ -333,10 +114,9 @@ public final class BlockUtils {
/**
* Determine if a given block should be affected by Super Breaker
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block should affected by Super Breaker, false
* otherwise
* otherwise
*/
public static Boolean affectedBySuperBreaker(BlockState blockState) {
if (mcMMO.getConfigManager().getExperienceMapManager().hasMiningXp(blockState.getType()))
@ -378,10 +158,9 @@ public final class BlockUtils {
/**
* Determine if a given block should be affected by Giga Drill Breaker
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block should affected by Giga Drill Breaker, false
* otherwise
* otherwise
*/
public static boolean affectedByGigaDrillBreaker(BlockState blockState) {
if(mcMMO.getConfigManager().getExperienceMapManager().hasExcavationXp(blockState.getType()))
@ -422,8 +201,7 @@ public final class BlockUtils {
/**
* Check if a given block is a log
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block is a log, false otherwise
*/
public static boolean isLog(BlockState blockState) {
@ -476,21 +254,26 @@ public final class BlockUtils {
/**
* Check if a given block is a leaf
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block is a leaf, false otherwise
*/
public static boolean isLeaves(BlockState blockState) {
return mcMMO.getMaterialMapStore().isLeavesWhiteListed(blockState.getType());
}
/**
* Determine if a given block should be affected by Flux Mining
*
* @param blockState The {@link BlockState} of the block to check
* @return true if the block should affected by Flux Mining, false otherwise
*/
public static boolean affectedByFluxMining(BlockState blockState) {
switch (blockState.getType()) {
case OAK_LEAVES:
case ACACIA_LEAVES:
case BIRCH_LEAVES:
case DARK_OAK_LEAVES:
case JUNGLE_LEAVES:
case SPRUCE_LEAVES:
case IRON_ORE:
case GOLD_ORE:
return true;
default :
default:
return false;
//return mcMMO.getModManager().isCustomLeaf(blockState);
}
@ -499,66 +282,39 @@ public final class BlockUtils {
/**
* Determine if a given block can activate Herbalism abilities
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block can be activate Herbalism abilities, false
* otherwise
* otherwise
*/
public static boolean canActivateHerbalism(BlockState blockState) {
switch (blockState.getType()) {
case DIRT :
case GRASS :
case GRASS_PATH :
case FARMLAND:
return false;
default :
return true;
}
return mcMMO.getMaterialMapStore().isHerbalismAbilityWhiteListed(blockState.getType());
}
/**
* Determine if a given block should be affected by Block Cracker
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block should affected by Block Cracker, false
* otherwise
* otherwise
*/
public static boolean affectedByBlockCracker(BlockState blockState) {
switch (blockState.getType()) {
case STONE_BRICKS:
return true;
default :
return false;
}
return mcMMO.getMaterialMapStore().isBlockCrackerWhiteListed(blockState.getType());
}
/**
* Determine if a given block can be made into Mycelium
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block can be made into Mycelium, false otherwise
*/
public static boolean canMakeShroomy(BlockState blockState) {
switch (blockState.getType()) {
case DIRT :
case GRASS :
case GRASS_PATH :
return true;
default :
return false;
}
return mcMMO.getMaterialMapStore().isShroomyWhiteListed(blockState.getType());
}
/**
* Determine if a given block is an mcMMO anvil
*
* @param blockState
* The {@link BlockState} of the block to check
* @param blockState The {@link BlockState} of the block to check
* @return true if the block is an mcMMO anvil, false otherwise
*/
public static boolean isMcMMOAnvil(BlockState blockState) {
@ -594,8 +350,7 @@ public final class BlockUtils {
BlockData data = blockState.getBlockData();
if (data.getMaterial() == Material.CACTUS || data.getMaterial() == Material.SUGAR_CANE)
return true;
if (data instanceof Ageable)
{
if (data instanceof Ageable) {
Ageable ageable = (Ageable) data;
return ageable.getAge() == ageable.getMaximumAge();
}

View File

@ -665,6 +665,7 @@ public final class ItemUtils {
* @return true if the item is a mining drop, false otherwise
*/
public static boolean isMiningDrop(ItemStack item) {
//TODO: 1.14 This needs to be updated
switch (item.getType()) {
case COAL:
case COAL_ORE:
@ -695,6 +696,7 @@ public final class ItemUtils {
* @return true if the item is a herbalism drop, false otherwise
*/
public static boolean isHerbalismDrop(ItemStack item) {
//TODO: 1.14 This needs to be updated
switch (item.getType()) {
case WHEAT:
case WHEAT_SEEDS:
@ -707,8 +709,8 @@ public final class ItemUtils {
case NETHER_WART:
case BROWN_MUSHROOM:
case RED_MUSHROOM:
case ROSE_RED:
case DANDELION_YELLOW:
case ROSE_BUSH:
case DANDELION:
case CACTUS:
case SUGAR_CANE:
case MELON:
@ -733,6 +735,7 @@ public final class ItemUtils {
* @return true if the item is a mob drop, false otherwise
*/
public static boolean isMobDrop(ItemStack item) {
//TODO: 1.14 This needs to be updated
switch (item.getType()) {
case STRING:
case FEATHER:
@ -774,7 +777,7 @@ public final class ItemUtils {
case ROTTEN_FLESH:
case GOLD_NUGGET:
case EGG:
case ROSE_RED:
case ROSE_BUSH:
case COAL:
return true;

View File

@ -0,0 +1,351 @@
package com.gmail.nossr50.util;
import org.bukkit.Material;
import java.util.HashSet;
/**
* Stores hash tables for item and block names
* This allows for better support across multiple versions of Minecraft
*
* This is a temporary class, mcMMO is spaghetti and I'l clean it up later
*
*/
public class MaterialMapStore {
private HashSet<String> abilityBlackList;
private HashSet<String> toolBlackList;
private HashSet<String> mossyWhiteList;
private HashSet<String> leavesWhiteList;
private HashSet<String> herbalismAbilityBlackList;
private HashSet<String> blockCrackerWhiteList;
private HashSet<String> canMakeShroomyWhiteList;
public MaterialMapStore()
{
abilityBlackList = new HashSet<>();
toolBlackList = new HashSet<>();
mossyWhiteList = new HashSet<>();
leavesWhiteList = new HashSet<>();
herbalismAbilityBlackList = new HashSet<>();
blockCrackerWhiteList = new HashSet<>();
canMakeShroomyWhiteList = new HashSet<>();
fillHardcodedHashSets();
}
public boolean isAbilityActivationBlackListed(Material material)
{
return abilityBlackList.contains(material.getKey().getKey());
}
public boolean isToolActivationBlackListed(Material material)
{
return toolBlackList.contains(material.getKey().getKey());
}
public boolean isMossyWhiteListed(Material material)
{
return mossyWhiteList.contains(material.getKey().getKey());
}
public boolean isLeavesWhiteListed(Material material)
{
return leavesWhiteList.contains(material.getKey().getKey());
}
public boolean isHerbalismAbilityWhiteListed(Material material)
{
return herbalismAbilityBlackList.contains(material.getKey().getKey());
}
public boolean isBlockCrackerWhiteListed(Material material)
{
return blockCrackerWhiteList.contains(material.getKey().getKey());
}
public boolean isShroomyWhiteListed(Material material)
{
return canMakeShroomyWhiteList.contains(material.getKey().getKey());
}
private void fillHardcodedHashSets()
{
fillAbilityBlackList();
filltoolBlackList();
fillMossyWhiteList();
fillLeavesWhiteList();
fillHerbalismAbilityBlackList();
fillBlockCrackerWhiteList();
fillShroomyWhiteList();
}
private void fillShroomyWhiteList()
{
canMakeShroomyWhiteList.add("dirt");
canMakeShroomyWhiteList.add("grass");
canMakeShroomyWhiteList.add("grass_path");
}
private void fillBlockCrackerWhiteList()
{
blockCrackerWhiteList.add("stone_bricks");
}
private void fillHerbalismAbilityBlackList()
{
herbalismAbilityBlackList.add("dirt");
herbalismAbilityBlackList.add("grass");
herbalismAbilityBlackList.add("grass_path");
herbalismAbilityBlackList.add("farmland");
}
private void fillLeavesWhiteList()
{
leavesWhiteList.add("oak_leaves");
leavesWhiteList.add("acacia_leaves");
leavesWhiteList.add("birch_leaves");
leavesWhiteList.add("dark_oak_leaves");
leavesWhiteList.add("jungle_leaves");
leavesWhiteList.add("spruce_leaves");
}
private void fillMossyWhiteList()
{
mossyWhiteList.add("cobblestone");
mossyWhiteList.add("dirt");
mossyWhiteList.add("grass_path");
mossyWhiteList.add("stone_bricks");
mossyWhiteList.add("cobblestone_wall");
}
private void fillAbilityBlackList()
{
abilityBlackList.add("black_bed");
abilityBlackList.add("blue_bed");
abilityBlackList.add("brown_bed");
abilityBlackList.add("cyan_bed");
abilityBlackList.add("gray_bed");
abilityBlackList.add("green_bed");
abilityBlackList.add("light_blue_bed");
abilityBlackList.add("light_gray_bed");
abilityBlackList.add("lime_bed");
abilityBlackList.add("magenta_bed");
abilityBlackList.add("orange_bed");
abilityBlackList.add("pink_bed");
abilityBlackList.add("purple_bed");
abilityBlackList.add("red_bed");
abilityBlackList.add("white_bed");
abilityBlackList.add("yellow_bed");
abilityBlackList.add("brewing_stand");
abilityBlackList.add("bookshelf");
abilityBlackList.add("cake");
abilityBlackList.add("chest");
abilityBlackList.add("dispenser");
abilityBlackList.add("enchanting_table");
abilityBlackList.add("ender_chest");
abilityBlackList.add("oak_fence_gate");
abilityBlackList.add("acacia_fence_gate");
abilityBlackList.add("dark_oak_fence_gate");
abilityBlackList.add("spruce_fence_gate");
abilityBlackList.add("birch_fence_gate");
abilityBlackList.add("jungle_fence_gate");
abilityBlackList.add("furnace");
abilityBlackList.add("jukebox");
abilityBlackList.add("lever");
abilityBlackList.add("note_block");
abilityBlackList.add("stone_button");
abilityBlackList.add("oak_button");
abilityBlackList.add("birch_button");
abilityBlackList.add("acacia_button");
abilityBlackList.add("dark_oak_button");
abilityBlackList.add("jungle_button");
abilityBlackList.add("spruce_button");
abilityBlackList.add("acacia_trapdoor");
abilityBlackList.add("birch_trapdoor");
abilityBlackList.add("dark_oak_trapdoor");
abilityBlackList.add("jungle_trapdoor");
abilityBlackList.add("oak_trapdoor");
abilityBlackList.add("spruce_trapdoor");
abilityBlackList.add("acacia_sign");
abilityBlackList.add("acacia_wall_sign");
abilityBlackList.add("birch_sign");
abilityBlackList.add("birch_wall_sign");
abilityBlackList.add("dark_oak_sign");
abilityBlackList.add("dark_oak_wall_sign");
abilityBlackList.add("jungle_sign");
abilityBlackList.add("jungle_wall_sign");
abilityBlackList.add("spruce_sign");
abilityBlackList.add("spruce_wall_sign");
abilityBlackList.add("oak_sign");
abilityBlackList.add("oak_wall_sign");
abilityBlackList.add("crafting_table");
abilityBlackList.add("beacon");
abilityBlackList.add("anvil");
abilityBlackList.add("dropper");
abilityBlackList.add("hopper");
abilityBlackList.add("trapped_chest");
abilityBlackList.add("iron_door");
abilityBlackList.add("iron_trapdoor");
abilityBlackList.add("oak_door");
abilityBlackList.add("acacia_door");
abilityBlackList.add("spruce_door");
abilityBlackList.add("birch_door");
abilityBlackList.add("jungle_door");
abilityBlackList.add("dark_oak_door");
abilityBlackList.add("oak_fence");
abilityBlackList.add("acacia_fence");
abilityBlackList.add("dark_oak_fence");
abilityBlackList.add("birch_fence");
abilityBlackList.add("jungle_fence");
abilityBlackList.add("spruce_fence");
abilityBlackList.add("armor_stand");
abilityBlackList.add("black_shulker_box");
abilityBlackList.add("blue_shulker_box");
abilityBlackList.add("brown_shulker_box");
abilityBlackList.add("cyan_shulker_box");
abilityBlackList.add("gray_shulker_box");
abilityBlackList.add("green_shulker_box");
abilityBlackList.add("light_blue_shulker_box");
abilityBlackList.add("lime_shulker_box");
abilityBlackList.add("magenta_shulker_box");
abilityBlackList.add("orange_shulker_box");
abilityBlackList.add("pink_shulker_box");
abilityBlackList.add("purple_shulker_box");
abilityBlackList.add("red_shulker_box");
abilityBlackList.add("light_gray_shulker_box");
abilityBlackList.add("white_shulker_box");
abilityBlackList.add("yellow_shulker_box");
abilityBlackList.add("wall_sign"); //1.13 and lower?
abilityBlackList.add("sign"); //1.13 and lower?
}
private void filltoolBlackList()
{
//TODO: Add anvils / missing logs
toolBlackList.add("black_bed");
toolBlackList.add("blue_bed");
toolBlackList.add("brown_bed");
toolBlackList.add("cyan_bed");
toolBlackList.add("gray_bed");
toolBlackList.add("green_bed");
toolBlackList.add("light_blue_bed");
toolBlackList.add("light_gray_bed");
toolBlackList.add("lime_bed");
toolBlackList.add("magenta_bed");
toolBlackList.add("orange_bed");
toolBlackList.add("pink_bed");
toolBlackList.add("purple_bed");
toolBlackList.add("red_bed");
toolBlackList.add("white_bed");
toolBlackList.add("yellow_bed");
toolBlackList.add("brewing_stand");
toolBlackList.add("bookshelf");
toolBlackList.add("cake");
toolBlackList.add("chest");
toolBlackList.add("dispenser");
toolBlackList.add("enchanting_table");
toolBlackList.add("ender_chest");
toolBlackList.add("oak_fence_gate");
toolBlackList.add("acacia_fence_gate");
toolBlackList.add("dark_oak_fence_gate");
toolBlackList.add("spruce_fence_gate");
toolBlackList.add("birch_fence_gate");
toolBlackList.add("jungle_fence_gate");
toolBlackList.add("furnace");
toolBlackList.add("jukebox");
toolBlackList.add("lever");
toolBlackList.add("note_block");
toolBlackList.add("stone_button");
toolBlackList.add("oak_button");
toolBlackList.add("birch_button");
toolBlackList.add("acacia_button");
toolBlackList.add("dark_oak_button");
toolBlackList.add("jungle_button");
toolBlackList.add("spruce_button");
toolBlackList.add("acacia_trapdoor");
toolBlackList.add("birch_trapdoor");
toolBlackList.add("dark_oak_trapdoor");
toolBlackList.add("jungle_trapdoor");
toolBlackList.add("oak_trapdoor");
toolBlackList.add("spruce_trapdoor");
toolBlackList.add("crafting_table");
toolBlackList.add("beacon");
toolBlackList.add("anvil");
toolBlackList.add("dropper");
toolBlackList.add("hopper");
toolBlackList.add("trapped_chest");
toolBlackList.add("iron_door");
toolBlackList.add("iron_trapdoor");
toolBlackList.add("oak_door");
toolBlackList.add("acacia_door");
toolBlackList.add("spruce_door");
toolBlackList.add("birch_door");
toolBlackList.add("jungle_door");
toolBlackList.add("dark_oak_door");
toolBlackList.add("oak_fence");
toolBlackList.add("acacia_fence");
toolBlackList.add("dark_oak_fence");
toolBlackList.add("birch_fence");
toolBlackList.add("jungle_fence");
toolBlackList.add("spruce_fence");
toolBlackList.add("armor_stand");
toolBlackList.add("black_shulker_box");
toolBlackList.add("blue_shulker_box");
toolBlackList.add("brown_shulker_box");
toolBlackList.add("cyan_shulker_box");
toolBlackList.add("gray_shulker_box");
toolBlackList.add("green_shulker_box");
toolBlackList.add("light_blue_shulker_box");
toolBlackList.add("lime_shulker_box");
toolBlackList.add("magenta_shulker_box");
toolBlackList.add("orange_shulker_box");
toolBlackList.add("pink_shulker_box");
toolBlackList.add("purple_shulker_box");
toolBlackList.add("red_shulker_box");
toolBlackList.add("light_gray_shulker_box");
toolBlackList.add("white_shulker_box");
toolBlackList.add("yellow_shulker_box");
toolBlackList.add("acacia_sign");
toolBlackList.add("acacia_wall_sign");
toolBlackList.add("birch_sign");
toolBlackList.add("birch_wall_sign");
toolBlackList.add("dark_oak_sign");
toolBlackList.add("dark_oak_wall_sign");
toolBlackList.add("jungle_sign");
toolBlackList.add("jungle_wall_sign");
toolBlackList.add("spruce_sign");
toolBlackList.add("spruce_wall_sign");
toolBlackList.add("oak_sign");
toolBlackList.add("oak_wall_sign");
toolBlackList.add("stripped_acacia_log");
toolBlackList.add("stripped_acacia_wood");
toolBlackList.add("stripped_birch_log");
toolBlackList.add("stripped_birch_wood");
toolBlackList.add("stripped_dark_oak_log");
toolBlackList.add("stripped_dark_oak_wood");
toolBlackList.add("stripped_jungle_log");
toolBlackList.add("stripped_jungle_wood");
toolBlackList.add("stripped_oak_log");
toolBlackList.add("stripped_oak_wood");
toolBlackList.add("stripped_spruce_log");
toolBlackList.add("stripped_spruce_wood");
toolBlackList.add("acacia_log");
toolBlackList.add("acacia_wood");
toolBlackList.add("birch_log");
toolBlackList.add("birch_wood");
toolBlackList.add("dark_oak_log");
toolBlackList.add("dark_oak_wood");
toolBlackList.add("jungle_log");
toolBlackList.add("jungle_wood");
toolBlackList.add("oak_log");
toolBlackList.add("oak_wood");
toolBlackList.add("spruce_log");
toolBlackList.add("spruce_wood");
}
private void addToHashSet(String string, HashSet<String> stringHashSet)
{
stringHashSet.add(string.toLowerCase());
}
}

View File

@ -451,9 +451,6 @@ public final class CombatUtils {
}
target.setMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY, mcMMO.metadataValue);
target.damage(damage, attacker);
// //IFrame storage

View File

@ -1,11 +1,10 @@
package com.gmail.nossr50.util.uuid;
import com.google.common.collect.ImmutableList;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
@ -17,7 +16,6 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
private static final int PROFILES_PER_REQUEST = 50;
private static final long RATE_LIMIT = 100L;
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
private final JSONParser jsonParser = new JSONParser();
private final List<String> names;
private final boolean rateLimiting;
@ -35,13 +33,22 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
for (int i = 0; i < requests; i++) {
HttpURLConnection connection = createConnection();
String body = JSONArray.toJSONString(names.subList(i * PROFILES_PER_REQUEST, Math.min((i + 1) * PROFILES_PER_REQUEST, names.size())));
List<String> nameSubList = names.subList(i * PROFILES_PER_REQUEST, Math.min((i + 1) * PROFILES_PER_REQUEST, names.size()));
JsonArray array = new JsonArray();
for(String name : nameSubList)
{
JsonPrimitive element = new JsonPrimitive(name);
array.add(element);
}
String body = array.getAsString();
writeBody(connection, body);
JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
for (Object profile : array) {
JSONObject jsonProfile = (JSONObject) profile;
String id = (String) jsonProfile.get("id");
String name = (String) jsonProfile.get("name");
JsonObject jsonProfile = (JsonObject) profile;
String id = jsonProfile.get("id").getAsString();
String name = jsonProfile.get("name").getAsString();
UUID uuid = UUIDFetcher.getUUID(id);
uuidMap.put(name, uuid);
}