mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-29 03:49:07 +00:00
1.2.20
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'net.momirealms'
|
||||
version = '1.2.19'
|
||||
version = '1.2.20'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -49,7 +49,7 @@ repositories {
|
||||
dependencies {
|
||||
compileOnly fileTree(dir:'libs',includes:['*.jar'])
|
||||
compileOnly('io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT')
|
||||
compileOnly('com.github.angeschossen:LandsAPI:6.5.1')
|
||||
compileOnly 'com.github.angeschossen:LandsAPI:6.26.18'
|
||||
compileOnly('com.zaxxer:HikariCP:5.0.1')
|
||||
compileOnly('com.github.Archy-X:AureliumSkills:Beta1.3.6')
|
||||
compileOnly('com.github.TechFortress:GriefPrevention:16.18')
|
||||
|
||||
@@ -20,6 +20,7 @@ package net.momirealms.customfishing.competition;
|
||||
import net.momirealms.customfishing.competition.bossbar.BossBarConfig;
|
||||
import net.momirealms.customfishing.object.action.ActionInterface;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -32,6 +33,8 @@ public class CompetitionConfig {
|
||||
private final List<String> startCommand;
|
||||
private final List<String> endCommand;
|
||||
private final List<String> joinCommand;
|
||||
private List<Integer> date;
|
||||
private List<Integer> weekday;
|
||||
private final CompetitionGoal goal;
|
||||
private final BossBarConfig bossBarConfig;
|
||||
private final boolean enableBossBar;
|
||||
@@ -94,4 +97,34 @@ public class CompetitionConfig {
|
||||
public HashMap<String, ActionInterface[]> getRewards() {
|
||||
return rewards;
|
||||
}
|
||||
|
||||
public void setDate(List<Integer> date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public void setWeekday(List<Integer> weekday) {
|
||||
this.weekday = weekday;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Calendar.getInstance().get(Calendar.DAY_OF_WEEK));
|
||||
}
|
||||
|
||||
public boolean canStart() {
|
||||
if (date != null && date.size() != 0) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int dateDay = calendar.get(Calendar.DATE);
|
||||
if (!date.contains(dateDay)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (weekday != null && weekday.size() != 0) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int dateDay = calendar.get(Calendar.DAY_OF_WEEK);
|
||||
if (!weekday.contains(dateDay)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class CompetitionSchedule extends Function {
|
||||
public void run() {
|
||||
if (isANewMinute()) {
|
||||
CompetitionConfig competitionConfig = CompetitionManager.competitionsT.get(getCurrentTime());
|
||||
if (competitionConfig != null) {
|
||||
if (competitionConfig != null && competitionConfig.canStart()) {
|
||||
startCompetition(competitionConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,26 +17,37 @@
|
||||
|
||||
package net.momirealms.customfishing.integration.antigrief;
|
||||
|
||||
import me.angeschossen.lands.api.flags.Flags;
|
||||
import me.angeschossen.lands.api.land.Area;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import me.angeschossen.lands.api.LandsIntegration;
|
||||
import me.angeschossen.lands.api.flags.types.RoleFlag;
|
||||
import me.angeschossen.lands.api.land.LandWorld;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customfishing.integration.AntiGriefInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LandsHook implements AntiGriefInterface {
|
||||
|
||||
private final LandsIntegration api;
|
||||
|
||||
public LandsHook() {
|
||||
api = LandsIntegration.of(CustomCrops.plugin);;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreak(Location location, Player player) {
|
||||
Area area = new me.angeschossen.lands.api.integration.LandsIntegration(CustomFishing.plugin).getAreaByLoc(location);
|
||||
if (area != null) return area.hasFlag(player, Flags.BLOCK_BREAK, false);
|
||||
else return true;
|
||||
LandWorld world = api.getWorld(location.getWorld());
|
||||
if (world != null) {
|
||||
return world.hasRoleFlag(player.getUniqueId(), location, RoleFlag.of("BLOCK_BREAK"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, Player player) {
|
||||
Area area = new me.angeschossen.lands.api.integration.LandsIntegration(CustomFishing.plugin).getAreaByLoc(location);
|
||||
if (area != null) return area.hasFlag(player, Flags.BLOCK_PLACE, false);
|
||||
else return true;
|
||||
LandWorld world = api.getWorld(location.getWorld());
|
||||
if (world != null) {
|
||||
return world.hasRoleFlag(player.getUniqueId(), location, RoleFlag.of("BLOCK_PLACE"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class PickUpListener implements Listener {
|
||||
public void onPickUp(PlayerAttemptPickupItemEvent event){
|
||||
ItemStack itemStack = event.getItem().getItemStack();
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
if (!nbtItem.hasKey("M_Owner")) return;
|
||||
if (!nbtItem.hasTag("M_Owner")) return;
|
||||
if (!Objects.equals(nbtItem.getString("M_Owner"), event.getPlayer().getName())){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class PickUpListener implements Listener {
|
||||
public void onMove(InventoryPickupItemEvent event){
|
||||
ItemStack itemStack = event.getItem().getItemStack();
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
if (!nbtItem.hasKey("M_Owner")) return;
|
||||
if (!nbtItem.hasTag("M_Owner")) return;
|
||||
nbtItem.removeKey("M_Owner");
|
||||
itemStack.setItemMeta(nbtItem.getItem().getItemMeta());
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import net.momirealms.customfishing.object.Function;
|
||||
import net.momirealms.customfishing.object.action.ActionInterface;
|
||||
import net.momirealms.customfishing.object.action.CommandActionImpl;
|
||||
import net.momirealms.customfishing.object.action.MessageActionImpl;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import net.momirealms.customfishing.util.ConfigUtil;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -93,6 +94,31 @@ public class CompetitionManager extends Function {
|
||||
rewardsMap
|
||||
);
|
||||
|
||||
if (config.contains(key + ".start-weekday")) {
|
||||
List<Integer> days = new ArrayList<>();
|
||||
for (String weekDay : config.getStringList(key + ".start-weekday")) {
|
||||
switch (weekDay) {
|
||||
case "Sunday" -> days.add(1);
|
||||
case "Monday" -> days.add(2);
|
||||
case "Tuesday" -> days.add(3);
|
||||
case "Wednesday" -> days.add(4);
|
||||
case "Thursday" -> days.add(5);
|
||||
case "Friday" -> days.add(6);
|
||||
case "Saturday" -> days.add(7);
|
||||
default -> AdventureUtil.consoleMessage("unknown weekday: " + weekDay);
|
||||
}
|
||||
}
|
||||
competitionConfig.setWeekday(days);
|
||||
}
|
||||
|
||||
if (config.contains(key + ".start-date")) {
|
||||
List<Integer> days = new ArrayList<>();
|
||||
for (String weekDay : config.getStringList(key + ".start-date")) {
|
||||
days.add(Integer.parseInt(weekDay));
|
||||
}
|
||||
competitionConfig.setDate(days);
|
||||
}
|
||||
|
||||
config.getStringList(key + ".start-time").forEach(time -> competitionsT.put(time, competitionConfig));
|
||||
competitionsC.put(key, competitionConfig);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.object.action;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public record PotionEffectImpl(PotionEffect potionEffect) implements ActionInterface {
|
||||
|
||||
@Override
|
||||
public void doOn(Player player, @Nullable Player anotherPlayer) {
|
||||
player.addPotionEffect(potionEffect);
|
||||
}
|
||||
}
|
||||
@@ -59,10 +59,10 @@ public class CustomPapi implements RequirementInterface {
|
||||
switch (type){
|
||||
case "==" -> papiRequirement = new PapiEquals(papi, value);
|
||||
case "!=" -> papiRequirement = new PapiNotEquals(papi, value);
|
||||
case ">=" -> papiRequirement = new PapiNoLess(papi, Double.parseDouble(value));
|
||||
case "<=" -> papiRequirement = new PapiNoLarger(papi, Double.parseDouble(value));
|
||||
case "<" -> papiRequirement = new PapiSmaller(papi, Double.parseDouble(value));
|
||||
case ">" -> papiRequirement = new PapiGreater(papi, Double.parseDouble(value));
|
||||
case ">=" -> papiRequirement = new PapiNoLess(papi, value);
|
||||
case "<=" -> papiRequirement = new PapiNoLarger(papi, value);
|
||||
case "<" -> papiRequirement = new PapiSmaller(papi, value);
|
||||
case ">" -> papiRequirement = new PapiGreater(papi, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,8 +70,8 @@ public class CustomPapi implements RequirementInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConditionMet(FishingCondition plantingCondition) {
|
||||
return papiRequirement.isMet(plantingCondition.getPapiMap());
|
||||
public boolean isConditionMet(FishingCondition fishingCondition) {
|
||||
return papiRequirement.isMet(fishingCondition.getPapiMap(), fishingCondition.getPlayer());
|
||||
}
|
||||
|
||||
private void addAndRequirements(List<PapiRequirement> requirements, Map<String, Object> map){
|
||||
@@ -105,10 +105,10 @@ public class CustomPapi implements RequirementInterface {
|
||||
switch (type){
|
||||
case "==" -> papiRequirements.add(new PapiEquals(papi, value));
|
||||
case "!=" -> papiRequirements.add(new PapiNotEquals(papi, value));
|
||||
case ">=" -> papiRequirements.add(new PapiNoLess(papi, Double.parseDouble(value)));
|
||||
case "<=" -> papiRequirements.add(new PapiNoLarger(papi, Double.parseDouble(value)));
|
||||
case "<" -> papiRequirements.add(new PapiSmaller(papi, Double.parseDouble(value)));
|
||||
case ">" -> papiRequirements.add(new PapiGreater(papi, Double.parseDouble(value)));
|
||||
case ">=" -> papiRequirements.add(new PapiNoLess(papi, value));
|
||||
case "<=" -> papiRequirements.add(new PapiNoLarger(papi, value));
|
||||
case "<" -> papiRequirements.add(new PapiSmaller(papi, value));
|
||||
case ">" -> papiRequirements.add(new PapiGreater(papi, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,5 @@ import net.momirealms.customfishing.object.fishing.FishingCondition;
|
||||
|
||||
public interface RequirementInterface {
|
||||
boolean isConditionMet(FishingCondition fishingCondition);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,15 +17,17 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements.papi;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public record ExpressionAnd(List<PapiRequirement> requirements) implements PapiRequirement{
|
||||
|
||||
@Override
|
||||
public boolean isMet(HashMap<String, String> papiMap) {
|
||||
public boolean isMet(HashMap<String, String> papiMap, Player player) {
|
||||
for (PapiRequirement requirement : requirements) {
|
||||
if (!requirement.isMet(papiMap)) return false;
|
||||
if (!requirement.isMet(papiMap, player)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -17,15 +17,17 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements.papi;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public record ExpressionOr(List<PapiRequirement> requirements) implements PapiRequirement{
|
||||
|
||||
@Override
|
||||
public boolean isMet(HashMap<String, String> papiMap) {
|
||||
public boolean isMet(HashMap<String, String> papiMap, Player player) {
|
||||
for (PapiRequirement requirement : requirements) {
|
||||
if (requirement.isMet(papiMap)) return true;
|
||||
if (requirement.isMet(papiMap, player)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,14 +17,17 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements.papi;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PapiEquals(String papi, String requirement) implements PapiRequirement{
|
||||
|
||||
@Override
|
||||
public boolean isMet(HashMap<String, String> papiMap) {
|
||||
public boolean isMet(HashMap<String, String> papiMap, Player player) {
|
||||
String value = papiMap.get(papi);
|
||||
return Objects.equals(value, requirement);
|
||||
return Objects.equals(value, PlaceholderAPI.setPlaceholders(player, requirement));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,16 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements.papi;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public record PapiGreater(String papi, double requirement) implements PapiRequirement{
|
||||
public record PapiGreater(String papi, String requirement) implements PapiRequirement{
|
||||
|
||||
@Override
|
||||
public boolean isMet(HashMap<String, String> papiMap) {
|
||||
public boolean isMet(HashMap<String, String> papiMap, Player player) {
|
||||
double value = Double.parseDouble(papiMap.get(papi));
|
||||
return value > requirement;
|
||||
return value > Double.parseDouble(PlaceholderAPI.setPlaceholders(player, requirement));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,16 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements.papi;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public record PapiNoLarger(String papi, double requirement) implements PapiRequirement{
|
||||
public record PapiNoLarger(String papi, String requirement) implements PapiRequirement{
|
||||
|
||||
@Override
|
||||
public boolean isMet(HashMap<String, String> papiMap) {
|
||||
public boolean isMet(HashMap<String, String> papiMap, Player player) {
|
||||
double value = Double.parseDouble(papiMap.get(papi));
|
||||
return value <= requirement;
|
||||
return value <= Double.parseDouble(PlaceholderAPI.setPlaceholders(player, requirement));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,16 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements.papi;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public record PapiNoLess(String papi, double requirement) implements PapiRequirement{
|
||||
public record PapiNoLess(String papi, String requirement) implements PapiRequirement{
|
||||
|
||||
@Override
|
||||
public boolean isMet(HashMap<String, String> papiMap) {
|
||||
public boolean isMet(HashMap<String, String> papiMap, Player player) {
|
||||
double value = Double.parseDouble(papiMap.get(papi));
|
||||
return value >= requirement;
|
||||
return value >= Double.parseDouble(PlaceholderAPI.setPlaceholders(player, requirement));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,17 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements.papi;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PapiNotEquals(String papi, String requirement) implements PapiRequirement{
|
||||
|
||||
@Override
|
||||
public boolean isMet(HashMap<String, String> papiMap) {
|
||||
public boolean isMet(HashMap<String, String> papiMap, Player player) {
|
||||
String value = papiMap.get(papi);
|
||||
return !Objects.equals(value, requirement);
|
||||
return !Objects.equals(value, PlaceholderAPI.setPlaceholders(player, requirement));
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,10 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements.papi;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface PapiRequirement {
|
||||
boolean isMet(HashMap<String, String> papiMap);
|
||||
boolean isMet(HashMap<String, String> papiMap, Player player);
|
||||
}
|
||||
|
||||
@@ -17,13 +17,16 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements.papi;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public record PapiSmaller(String papi, double requirement) implements PapiRequirement{
|
||||
public record PapiSmaller(String papi, String requirement) implements PapiRequirement{
|
||||
|
||||
@Override
|
||||
public boolean isMet(HashMap<String, String> papiMap) {
|
||||
public boolean isMet(HashMap<String, String> papiMap, Player player) {
|
||||
double value = Double.parseDouble(papiMap.get(papi));
|
||||
return value < requirement;
|
||||
return value < Double.parseDouble(PlaceholderAPI.setPlaceholders(player, requirement));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,15 @@ example:
|
||||
# RANDOM
|
||||
goal: CATCH_AMOUNT
|
||||
|
||||
#Optional
|
||||
#start-weekday:
|
||||
# - monday
|
||||
# - sunday
|
||||
#Optional
|
||||
#start-date:
|
||||
# - 1
|
||||
# - 7
|
||||
# - 14
|
||||
# optional
|
||||
# Fishing competition can also be started with a command
|
||||
start-time:
|
||||
|
||||
@@ -54,9 +54,14 @@ rainbow_fish:
|
||||
namespace: '(String) momirealms'
|
||||
id: '(String) rainbow_fish'
|
||||
|
||||
# Available events: success/failure/hook
|
||||
# Available actions: message/command/exp/mending/skill-xp/sound
|
||||
# Available events: eat/success/failure/hook
|
||||
# Available actions: message/command/exp/mending/skill-xp/sound/potion-effect
|
||||
action:
|
||||
eat:
|
||||
potion-effect:
|
||||
type: blindness
|
||||
level: 1
|
||||
duration: 200
|
||||
success:
|
||||
message:
|
||||
- 'You got a {loot} lol!'
|
||||
@@ -180,8 +185,9 @@ rainbow_fish:
|
||||
'&&':
|
||||
condition_1:
|
||||
type: '>='
|
||||
# compare two placeholders
|
||||
papi: '%player_health%'
|
||||
value: 5
|
||||
value: '%player_y%'
|
||||
condition_2:
|
||||
type: '<'
|
||||
papi: '%player_health%'
|
||||
|
||||
Reference in New Issue
Block a user