Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into tridentsxbows

This commit is contained in:
nossr50
2020-11-11 16:42:53 -08:00
197 changed files with 11978 additions and 9566 deletions

View File

@@ -1,50 +0,0 @@
package com.gmail.nossr50.runnables.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PartyChatTask extends BukkitRunnable {
private final Plugin plugin;
private final Party party;
private final String senderName;
private final String displayName;
private String message;
public PartyChatTask(Plugin plugin, Party party, String senderName, String displayName, String message) {
this.plugin = plugin;
this.party = party;
this.senderName = senderName;
this.displayName = displayName;
this.message = message;
}
@Override
public void run() {
if (Config.getInstance().getPartyChatColorLeaderName() && senderName.equalsIgnoreCase(party.getLeader().getPlayerName())) {
message = message.replaceFirst(Pattern.quote(displayName), ChatColor.GOLD + Matcher.quoteReplacement(displayName) + ChatColor.RESET);
}
for (Player member : party.getPartyMembers()) {
member.sendMessage(message);
}
if (party.getAlly() != null) {
for (Player member : party.getAlly().getPartyMembers()) {
String allyPrefix = LocaleLoader.formatString(Config.getInstance().getPartyChatPrefixAlly());
member.sendMessage(allyPrefix + message);
}
}
plugin.getServer().getConsoleSender().sendMessage(ChatColor.stripColor("[mcMMO] [P]<" + party.getPartyName() + ">" + message));
}
}

View File

@@ -69,9 +69,11 @@ public class BleedTimerTask extends BukkitRunnable {
}
//Count Armor
for(ItemStack armorPiece : ((Player) target).getInventory().getArmorContents())
{
armorCount++;
for (ItemStack armorPiece : ((Player) target).getInventory().getArmorContents()) {
//We only want to count slots that contain armor.
if (armorPiece != null) {
armorCount++;
}
}
} else {

View File

@@ -11,8 +11,11 @@ import org.bukkit.block.BlockState;
import org.bukkit.block.data.Ageable;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.type.Cocoa;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class DelayedCropReplant extends BukkitRunnable {
@@ -21,7 +24,7 @@ public class DelayedCropReplant extends BukkitRunnable {
private final Material cropMaterial;
private boolean wasImmaturePlant;
private final BlockBreakEvent blockBreakEvent;
private BlockFace cropFace;
private @Nullable BlockFace cropFace;
/**
* Replants a crop after a delay setting the age to desiredCropAge
@@ -48,6 +51,7 @@ public class DelayedCropReplant extends BukkitRunnable {
public void run() {
Block cropBlock = cropLocation.getBlock();
BlockState currentState = cropBlock.getState();
PlantAnchorType plantAnchorType = PlantAnchorType.NORMAL;
//Remove the metadata marking the block as recently replanted
new markPlantAsOld(blockBreakEvent.getBlock().getLocation()).runTaskLater(mcMMO.p, 10);
@@ -81,6 +85,10 @@ public class DelayedCropReplant extends BukkitRunnable {
directional.setFacing(cropFace);
newState.setBlockData(directional);
if(newData instanceof Cocoa) {
plantAnchorType = PlantAnchorType.COCOA;
}
}
//Age the crop
@@ -89,15 +97,69 @@ public class DelayedCropReplant extends BukkitRunnable {
newState.setBlockData(ageable);
newState.update(true);
newState.update(true, true);
//Play an effect
ParticleEffectUtils.playGreenThumbEffect(cropLocation);
new PhysicsBlockUpdate(newState.getBlock(), cropFace, plantAnchorType).runTaskLater(mcMMO.p, 1);
}
}
private enum PlantAnchorType {
NORMAL,
COCOA
}
private static class PhysicsBlockUpdate extends BukkitRunnable {
private final Block plantBlock;
private final PlantAnchorType plantAnchorType;
private BlockFace plantFace;
private PhysicsBlockUpdate(@NotNull Block plantBlock, @Nullable BlockFace plantFace, @NotNull PlantAnchorType plantAnchorType) {
this.plantBlock = plantBlock;
this.plantAnchorType = plantAnchorType;
if(plantFace != null) {
this.plantFace = plantFace;
}
}
@Override
public void run() {
//Update neighbors
switch (plantAnchorType) {
case COCOA:
checkPlantIntegrity(plantFace);
break;
case NORMAL:
checkPlantIntegrity(BlockFace.DOWN);
break;
}
}
private void checkPlantIntegrity(@NotNull BlockFace blockFace) {
Block neighbor = plantBlock.getRelative(blockFace);
if(plantAnchorType == PlantAnchorType.COCOA) {
if(!neighbor.getType().toString().toLowerCase().contains("jungle")) {
plantBlock.breakNaturally();
}
} else {
switch (neighbor.getType()) {
case AIR:
case CAVE_AIR:
case WATER:
case LAVA:
plantBlock.breakNaturally();
break;
default:
}
}
}
}
private static class markPlantAsOld extends BukkitRunnable {
private final Location cropLoc;

View File

@@ -0,0 +1,21 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.skills.fishing.FishingManager;
import org.bukkit.entity.FishHook;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
public class MasterAnglerTask extends BukkitRunnable {
private final @NotNull FishHook fishHook;
private final @NotNull FishingManager fishingManager;
public MasterAnglerTask(@NotNull FishHook fishHook, @NotNull FishingManager fishingManager) {
this.fishHook = fishHook;
this.fishingManager = fishingManager;
}
@Override
public void run() {
fishingManager.processMasterAngler(fishHook);
}
}