Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ the "copyright" line and a pointer to where the full notice is found.

OpenMC PluginV2 is used for the OpenMC Minecraft server created
by Aywen.
Copyright (C) 2025 OpenMC
Copyright (C) 2026 OpenMC

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
Expand All @@ -653,7 +653,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

OpenMC - PluginV2 Copyright (C) 2025 OpenMC
OpenMC - PluginV2 Copyright (C) 2026 OpenMC
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/fr/openmc/api/omcplayer/OMCOfflinePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
@SuppressWarnings({"unused", "removal", "deprecation"})
public interface OMCOfflinePlayer extends OfflinePlayer {
static OMCOfflinePlayer of(UUID playerUUID) {
if (playerUUID == null) return null;
OfflinePlayer offlinePlayer = CacheOfflinePlayer.getOfflinePlayer(playerUUID);
return new OMCOfflinePlayerImpl(offlinePlayer);
}

static OMCOfflinePlayer of(String playerName) {
if (playerName == null) return null;
OfflinePlayer offlinePlayer = CacheOfflinePlayer.getOfflinePlayer(playerName);
return new OMCOfflinePlayerImpl(offlinePlayer);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/fr/openmc/api/omcplayer/OMCPlayerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ static OMCPlayer of(UUID playerUUID) {

@Override
public @Nullable CraftPlayer getCraftPlayer() {
if (player == null) return null;
if (player instanceof OMCPlayer omcPlayer)
return omcPlayer.getCraftPlayer();

return (CraftPlayer) player;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public OMCPlayerCity(Player player) {

@Nullable
public City getCity() {
return CityManager.getCity(getUniqueId());
return CityManager.getPlayerCity(getUniqueId());
}

public boolean hasCity() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package fr.openmc.core.features.chatanimations.contents.challenge;

import com.destroystokyo.paper.event.player.PlayerJumpEvent;
import dev.lone.itemsadder.api.Events.CustomBlockBreakEvent;
import dev.lone.itemsadder.api.Events.CustomBlockPlaceEvent;
import fr.openmc.core.features.chatanimations.ChatAnimation;
import fr.openmc.core.features.chatanimations.ChatAnimationManager;
import fr.openmc.core.features.chatanimations.contents.challenge.types.*;
Expand Down Expand Up @@ -32,6 +34,22 @@ public void onBlockBreak(BlockBreakEvent event) {
animation.complete(winner);
}
}
@EventHandler
public void onCustomBlockBreak(CustomBlockBreakEvent event) {
ChatAnimation animation = ChatAnimationManager.getActive();
if (animation == null) return;
if (!(animation instanceof MineBlocksChallenge challenge)) return;
if (animation.isFinished()) return;
if (!challenge.getKeyBlock().matches(event.getBlock())) return;

Player player = event.getPlayer();
int count = challenge.getProgress().merge(player.getUniqueId(), 1, Integer::sum);

if (count >= challenge.getTarget()) {
Player winner = event.getPlayer();
animation.complete(winner);
}
}

@EventHandler
public void onJump(PlayerJumpEvent event) {
Expand Down Expand Up @@ -125,6 +143,22 @@ public void onBlockPlace(BlockPlaceEvent event) {
}
}

@EventHandler
public void onCustomBlockPlace(CustomBlockPlaceEvent event) {
ChatAnimation animation = ChatAnimationManager.getActive();
if (animation == null) return;
if (!(animation instanceof PlaceBlocksChallenge challenge)) return;
if (animation.isFinished()) return;
if (!challenge.getKeyBlock().matches(event.getBlock())) return;

Player player = event.getPlayer();
int count = challenge.getProgress().merge(player.getUniqueId(), 1, Integer::sum);

if (count >= challenge.getTarget()) {
animation.complete(player);
}
}

@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if (event.getFrom().distanceSquared(event.getTo()) == 0) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public Set<CustomLoot> getLoots() {
new MoneyLoot(200, 450, 1),
new ItemLoot(OMCRegistry.CUSTOM_ITEMS.CONTEST_SHELL,
(player) -> WeeklyEventsManager.isEventActive()
&& WeeklyEventsManager.getCurrentEvent() instanceof Contest contest
&& ContestPhase.TRADE_PHASE.getPhase().equals(contest.getActivePhase()),
&& WeeklyEventsManager.getCurrentEvent() instanceof Contest
&& ContestPhase.TRADE_PHASE.getPhase() == WeeklyEventsManager.getCurrentPhase(),
1,
100
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public Set<CustomLoot> getLoots() {
new MoneyLoot(100, 300, 1),
new ItemLoot(OMCRegistry.CUSTOM_ITEMS.CONTEST_SHELL,
(player) -> WeeklyEventsManager.isEventActive()
&& WeeklyEventsManager.getCurrentEvent() instanceof Contest contest
&& ContestPhase.TRADE_PHASE.getPhase().equals(contest.getActivePhase()),
&& WeeklyEventsManager.getCurrentEvent() instanceof Contest
&& ContestPhase.TRADE_PHASE.getPhase() == WeeklyEventsManager.getCurrentPhase(),
1,
50
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import fr.openmc.core.features.city.CityPermission;
import fr.openmc.core.features.city.menu.CityModifyMenu;
import fr.openmc.core.features.city.sub.milestone.rewards.MemberLimitRewards;
import fr.openmc.core.utils.cache.CachePlayerName;
import fr.openmc.core.utils.text.messages.MessageType;
import fr.openmc.core.utils.text.messages.MessagesManager;
import fr.openmc.core.utils.text.messages.Prefix;
Expand Down Expand Up @@ -36,7 +35,7 @@ public static void init(Menu menu, Map<Integer, ItemMenuBuilder> contents, City
));
itemMeta.lore(getDynamicLore(city, player));
itemMeta.setItemModel(NamespacedKey.minecraft("air"));
}).setOnClick(inventoryClickEvent -> {
}).setOnClick(_ -> {
City cityCheck = CityManager.getPlayerCity(player.getUniqueId());
if (cityCheck == null) {
MessagesManager.sendMessage(player, TranslationManager.translation("messages.city.player_no_in_city"), Prefix.CITY, MessageType.ERROR, false);
Expand All @@ -53,7 +52,7 @@ private static List<Component> getDynamicLore(City city, Player player) {
boolean hasPermissionRenameCity = city.hasPermission(player.getUniqueId(), CityPermission.RENAME);
boolean hasPermissionOwner = city.hasPermission(player.getUniqueId(), CityPermission.OWNER);

Component mayorName = (city.getMayor() != null && city.getMayor().getName() != null)
Component mayorName = (city.getMayor() != null && city.getMayor().getOMCOfflinePlayer() != null)
? city.getMayor().getOMCOfflinePlayer().getNameWithHead()
: TranslationManager.translation("messages.menus.none");
NamedTextColor mayorColor = (city.getMayor() != null && city.getMayor().getName() != null) ? city.getMayor().getMayorColor() : NamedTextColor.DARK_GRAY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static Supplier<ItemMenuBuilder> getItemSupplier(Menu menu, City city, P

private static List<Component> getDynamicLore(City city, Player player) {
boolean hasPermissionOwner = city.hasPermission(player.getUniqueId(), CityPermission.OWNER);
Component mayorName = (city.getMayor() != null && city.getMayor().getName() != null)
Component mayorName = (city.getMayor() != null && city.getMayor().getOMCOfflinePlayer() != null)
? city.getMayor().getOMCOfflinePlayer().getNameWithHead()
: TranslationManager.translation("messages.menus.none");
NamedTextColor mayorColor = (city.getMayor() != null && city.getMayor().getName() != null) ? city.getMayor().getMayorColor() : NamedTextColor.DARK_GRAY;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.openmc.core.features.dream.models.registry;

import fr.openmc.core.registry.loottable.CustomLootTable;
import fr.openmc.core.registry.loottable.loots.CustomLoot;
import fr.openmc.core.registry.mobs.CustomMob;
import fr.openmc.core.registry.mobs.CustomMobAttribute;
Expand All @@ -20,6 +21,12 @@ public DreamMob(String id, Component name, Class<T> entityClass, double health,
this.damageTime = damageTime;
}

public DreamMob(String id, Component name, Class<T> entityClass, double health, Long damageTime, double speed, double scale, CustomLootTable loots) {
super(id, name, entityClass, health, 0f, speed, loots,
new CustomMobAttribute(Attribute.SCALE, scale));
this.damageTime = damageTime;
}

public DreamMob(String id, Component name, Class<T> entityClass, double health, Long damageTime, double speed, double scale, List<CustomLoot> loots) {
super(id, name, entityClass, health, 0f, speed, loots,
new CustomMobAttribute(Attribute.SCALE, scale));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BankCommands {
@CommandPlaceholder()
@Description("Ouvre le menu de votre banque personelle")
public static void openBankMenu(OMCPlayer player) {
if (player.city().hasCity() || !FeaturesRewards.hasUnlockFeature(player.city().getCity(), FeaturesRewards.Feature.PLAYER_BANK)) {
if (!player.city().hasCity() || !FeaturesRewards.hasUnlockFeature(player.city().getCity(), FeaturesRewards.Feature.PLAYER_BANK)) {
player.message().sendError(
TranslationManager.translation(
"feature.economy.bank.command.not_unlocked",
Expand All @@ -39,7 +39,7 @@ void deposit(
OMCPlayer player,
@Named("montant") String input
) {
if (player.city().hasCity() || !FeaturesRewards.hasUnlockFeature(player.city().getCity(), FeaturesRewards.Feature.PLAYER_BANK)) {
if (!player.city().hasCity() || !FeaturesRewards.hasUnlockFeature(player.city().getCity(), FeaturesRewards.Feature.PLAYER_BANK)) {
player.message().sendError(
TranslationManager.translation(
"feature.economy.bank.command.not_unlocked",
Expand All @@ -59,7 +59,7 @@ void withdraw(
OMCPlayer player,
@Named("montant") String input
) {
if (player.city().hasCity() || !FeaturesRewards.hasUnlockFeature(player.city().getCity(), FeaturesRewards.Feature.PLAYER_BANK)) {
if (!player.city().hasCity() || !FeaturesRewards.hasUnlockFeature(player.city().getCity(), FeaturesRewards.Feature.PLAYER_BANK)) {
player.message().sendError(
TranslationManager.translation(
"feature.economy.bank.command.not_unlocked",
Expand All @@ -75,12 +75,13 @@ void withdraw(

@Subcommand({"balance", "bal"})
void withdraw(OMCPlayer player) {
if (player.city().hasCity() || !FeaturesRewards.hasUnlockFeature(player.city().getCity(), FeaturesRewards.Feature.PLAYER_BANK)) {
if (!player.city().hasCity() || !FeaturesRewards.hasUnlockFeature(player.city().getCity(), FeaturesRewards.Feature.PLAYER_BANK)) {
player.message().sendError(
TranslationManager.translation(
"feature.economy.bank.command.not_unlocked",
Component.text(FeaturesRewards.getFeatureUnlockLevel(FeaturesRewards.Feature.PLAYER_BANK)).color(NamedTextColor.YELLOW)
), Prefix.CITY);
return;
}

double balance = BankManager.getBankBalance(player.getUniqueId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import fr.openmc.core.utils.text.messages.TranslationManager;
import net.kyori.adventure.text.Component;
import org.bukkit.inventory.ItemType;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

import java.util.LinkedHashSet;
import java.util.List;
Expand All @@ -26,10 +28,12 @@ public String getNamespace() {
@Override
public Set<CustomLoot> getLoots() {
return new LinkedHashSet<>(List.of(
new ItemLoot(OMCRegistry.CUSTOM_ITEMS.AYWENITE_BLOCK,1, 1, 10),
new ItemLoot(OMCRegistry.CUSTOM_ITEMS.AYWENITE_BLOCK,1, 7, 15),
new ItemLoot(ItemType.OMINOUS_BOTTLE.createItemStack(
o -> o.setAmplifier(4)),0.7, 1),
new ItemLoot(OMCRegistry.CUSTOM_ITEMS.VAMPIRE_HEAD,0.50, 1),
new ItemLoot(ItemType.SPLASH_POTION.createItemStack(p ->
p.addCustomEffect(new PotionEffect(PotionEffectType.INSTANT_HEALTH, 5, 1), true)), 0.7, 1, 3),
new ItemLoot(OMCRegistry.CUSTOM_ITEMS.VAMPIRE_HEAD, 0.5, 1),
new ItemLoot(
OMCRegistry.CUSTOM_ENCHANTS.VAMPIRISM.getEnchantedBookItem(1, 2),
0.35,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
import org.bukkit.inventory.ItemType;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

import java.util.LinkedHashSet;
import java.util.List;
Expand All @@ -31,6 +33,8 @@ public Set<CustomLoot> getLoots() {
new ItemLoot(Material.IRON_BLOCK,0.23, 1),
new ItemLoot(Material.GOLDEN_APPLE,0.2, 1, 2),
new ItemLoot(Material.GOLD_BLOCK,0.16, 1),
new ItemLoot(ItemType.SPLASH_POTION.createItemStack(p ->
p.addCustomEffect(new PotionEffect(PotionEffectType.INSTANT_HEALTH, 5, 1), true)), 0.13, 1),
new ItemLoot(ItemType.OMINOUS_BOTTLE.createItemStack(o ->
o.setAmplifier(4)),0.13, 1, 2),
new ItemLoot(Material.DIAMOND,0.1, 1, 2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AncientMonster(String id) {
Monster.class,
3,
1,
OMCRegistry.CUSTOM_LOOT_TABLES.ANCIENT_MOB.rollLoots().loots()
OMCRegistry.CUSTOM_LOOT_TABLES.ANCIENT_MOB
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public CorruptedMonster(String id) {
Monster.class,
1,
1,
OMCRegistry.CUSTOM_LOOT_TABLES.CORRUPTED_MOB.rollLoots().loots()
OMCRegistry.CUSTOM_LOOT_TABLES.CORRUPTED_MOB
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public CursedMonster(String id) {
Monster.class,
1,
1,
OMCRegistry.CUSTOM_LOOT_TABLES.CURSED_MOB.rollLoots().loots()
OMCRegistry.CUSTOM_LOOT_TABLES.CURSED_MOB
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public EnragedMonster(String id) {
Monster.class,
1,
1,
OMCRegistry.CUSTOM_LOOT_TABLES.ENRAGED_MOB.rollLoots().loots()
OMCRegistry.CUSTOM_LOOT_TABLES.ENRAGED_MOB
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void showLoot(Player player) {
new LootsInfoMenu(
player,
TranslationManager.translation("feature.dailyevents.miraculousfishing.menu.loot_info.sea_creature"),
seaCreatureMob.getMob().getLoots()
seaCreatureMob.getMob().getLootTable().getLoots()
).open();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
@Credit(developers = {"Axeno"})
public class FriendManager extends Feature implements HasDatabase, HasCommands {

// TODO: Configuration pour activer/désactiver les demandes d'amis (par défaut activé) & les messages de connexion/déconnexion
// Config: accepter que les joueurs voient l'argent, la ville, le status (En ligne, Hors ligne), le temps de jeu, ou autre

@Getter
public static final List<FriendRequest> friendsRequests = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ private static boolean sendLetter(OMCPlayer sender, OMCOfflinePlayer receiver, I
letters.add(letter);

int id = letter.getLetterId();
OMCPlayer receiverPlayer = OMCPlayer.of(receiver.getPlayer()) ;
if (receiverPlayer != null) {
if (receiver.isOnline()) {
OMCPlayer receiverPlayer = OMCPlayer.of(receiver.getPlayer());
if (receiverPlayer == null) return true;
Inventory inv = receiverPlayer.getInventory();
if (inv instanceof PlayerMailbox receiverMailbox) receiverMailbox.open();
if (inv instanceof PlayerMailbox receiverMailbox)
receiverMailbox.open();
sendLetterReceivedNotification(sender, receiverPlayer, numItems, id);
}

Expand Down Expand Up @@ -148,40 +150,6 @@ private static ItemStack[] changeStackItem(ItemStack[] items) {
.toArray(ItemStack[]::new);
}

public static void sendMailNotification(Player player) {
long count = letters.stream()
.filter(letter -> letter.getReceiverUUID().equals(player.getUniqueId()) && !letter.isRefused())
.count();

if (count == 0) return;

Component countLabel = count > 1
? Component.text(count)
: TranslationManager.translation("feature.mailboxes.message.one_letter");
Component line1 = TranslationManager.translation(
"feature.mailboxes.message.new_letters.line1",
countLabel.color(NamedTextColor.GREEN),
pluralize(TranslationManager.translation("feature.mailboxes.letter"), count).color(NamedTextColor.DARK_GREEN)
).color(NamedTextColor.DARK_GREEN);
Component clickComponent = TranslationManager.translation("feature.mailboxes.message.new_letters.click")
.color(NamedTextColor.YELLOW)
.clickEvent(ClickEvent.runCommand("/mailbox"))
.hoverEvent(getHoverEvent(TranslationManager.translation("feature.mailboxes.message.new_letters.hover")));
Component line2 = clickComponent
.append(Component.space())
.append(TranslationManager.translation("feature.mailboxes.message.new_letters.suffix")
.color(NamedTextColor.GOLD));
Component message = line1.appendNewline().append(line2);

MessagesManager.sendMessage(
player,
message,
Prefix.MAILBOX,
MessageType.SUCCESS,
true
);
}

public static boolean deleteLetter(int id) {
return letters.removeIf(letter -> letter.getLetterId() == id);
}
Expand Down
Loading
Loading