mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-28 03:19:15 +00:00
3.1.2
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.customcrops.api.customplugin.crucible;
|
||||
|
||||
import net.momirealms.customcrops.api.customplugin.Handler;
|
||||
import net.momirealms.customcrops.api.customplugin.PlatformManager;
|
||||
|
||||
public class CrucibleHandler extends Handler {
|
||||
|
||||
public CrucibleHandler(PlatformManager platformManager) {
|
||||
super(platformManager);
|
||||
//TODO NO API Events
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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.customcrops.api.customplugin.crucible;
|
||||
|
||||
import io.lumine.mythic.bukkit.BukkitAdapter;
|
||||
import io.lumine.mythiccrucible.MythicCrucible;
|
||||
import io.lumine.mythiccrucible.items.CrucibleItem;
|
||||
import io.lumine.mythiccrucible.items.blocks.CustomBlockItemContext;
|
||||
import net.momirealms.customcrops.api.customplugin.PlatformInterface;
|
||||
import net.momirealms.customcrops.api.util.AdventureUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.ItemDisplay;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class CruciblePluginImpl implements PlatformInterface {
|
||||
|
||||
@Override
|
||||
public boolean removeCustomBlock(Location location) {
|
||||
Optional<CustomBlockItemContext> optionalCB = MythicCrucible.inst().getItemManager().getCustomBlockManager().getBlockFromBlock(location.getBlock());
|
||||
if (optionalCB.isEmpty()) return false;
|
||||
optionalCB.get().remove(location.getBlock(), null, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getCustomBlockID(Location location) {
|
||||
Optional<CustomBlockItemContext> optionalCB = MythicCrucible.inst().getItemManager().getCustomBlockManager().getBlockFromBlock(location.getBlock());
|
||||
if (optionalCB.isEmpty()) return null;
|
||||
else return optionalCB.get().getCrucibleItem().getInternalName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack getItemStack(String id) {
|
||||
Optional<CrucibleItem> optionalCI = MythicCrucible.inst().getItemManager().getItem(id);
|
||||
if (optionalCI.isEmpty()) return null;
|
||||
else return BukkitAdapter.adapt(optionalCI.get().getMythicItem().generateItemStack(1));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemFrame placeItemFrame(Location location, String id) {
|
||||
Optional<CrucibleItem> optionalCI = MythicCrucible.inst().getItemManager().getItem(id);
|
||||
if (optionalCI.isPresent()) {
|
||||
optionalCI.get().getFurnitureData().place(location.getBlock(), BlockFace.UP, 0);
|
||||
} else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrop] ItemFrame not exists: " + id);
|
||||
}
|
||||
//TODO API limits (It's using private methods to place)
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemDisplay placeItemDisplay(Location location, String id) {
|
||||
//TODO Not implemented feature
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeNoteBlock(Location location, String id) {
|
||||
Optional<CrucibleItem> optionalCI = MythicCrucible.inst().getItemManager().getItem(id);
|
||||
if (optionalCI.isPresent()) {
|
||||
location.getBlock().setBlockData(optionalCI.get().getBlockData().getBlockData());
|
||||
} else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrop] NoteBlock not exists: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeTripWire(Location location, String id) {
|
||||
Optional<CrucibleItem> optionalCI = MythicCrucible.inst().getItemManager().getItem(id);
|
||||
if (optionalCI.isPresent()) {
|
||||
location.getBlock().setBlockData(optionalCI.get().getBlockData().getBlockData());
|
||||
} else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrop] Tirpwire not exists: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getBlockID(Block block) {
|
||||
Optional<CustomBlockItemContext> optionalCB = MythicCrucible.inst().getItemManager().getCustomBlockManager().getBlockFromBlock(block);
|
||||
if (optionalCB.isEmpty()) return block.getType().name();
|
||||
else return optionalCB.get().getCrucibleItem().getInternalName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesItemExist(String id) {
|
||||
Optional<CrucibleItem> optionalCI = MythicCrucible.inst().getItemManager().getItem(id);
|
||||
return optionalCI.isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropBlockLoot(Block block) {
|
||||
//TODO Not necessary
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeChorus(Location location, String id) {
|
||||
Optional<CrucibleItem> optionalCI = MythicCrucible.inst().getItemManager().getItem(id);
|
||||
if (optionalCI.isPresent()) {
|
||||
location.getBlock().setBlockData(optionalCI.get().getBlockData().getBlockData());
|
||||
} else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrop] Chorus not exists: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getItemStackID(@NotNull ItemStack itemStack) {
|
||||
Optional<CrucibleItem> optionalCI = MythicCrucible.inst().getItemManager().getItem(itemStack);
|
||||
if (optionalCI.isEmpty()) return itemStack.getType().name();
|
||||
else return optionalCI.get().getInternalName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getItemDisplayID(ItemDisplay itemDisplay) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getItemFrameID(ItemFrame itemFrame) {
|
||||
Optional<CrucibleItem> optionalCI = MythicCrucible.inst().getItemManager().getFurnitureManager().getItemFromFrame(itemFrame);
|
||||
if (optionalCI.isEmpty()) return null;
|
||||
else return optionalCI.get().getInternalName();
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class ItemsAdderPluginImpl implements PlatformInterface {
|
||||
if (entity instanceof ItemFrame itemFrame)
|
||||
return itemFrame;
|
||||
else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Item Frame not exists: " + id);
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] ItemFrame not exists: " + id);
|
||||
customFurniture.remove(false);
|
||||
}
|
||||
return null;
|
||||
@@ -85,7 +85,7 @@ public class ItemsAdderPluginImpl implements PlatformInterface {
|
||||
if (entity instanceof ItemDisplay itemDisplay)
|
||||
return itemDisplay;
|
||||
else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Item Display not exists: " + id);
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] ItemDisplay not exists: " + id);
|
||||
customFurniture.remove(false);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class OraxenPluginImpl implements PlatformInterface {
|
||||
if (entity instanceof ItemFrame itemFrame)
|
||||
return itemFrame;
|
||||
else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Item Frame not exists: " + id);
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] ItemFrame not exists: " + id);
|
||||
entity.remove();
|
||||
return null;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class OraxenPluginImpl implements PlatformInterface {
|
||||
if (entity instanceof ItemDisplay itemDisplay)
|
||||
return itemDisplay;
|
||||
else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Item Display not exists: " + id);
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] ItemDisplay not exists: " + id);
|
||||
entity.remove();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class CustomCropsCommand extends AbstractMainCommand {
|
||||
regSubCommand(ForceCommand.INSTANCE);
|
||||
regSubCommand(MigrateCommand.INSTANCE);
|
||||
regSubCommand(ConvertCommand.INSTANCE);
|
||||
// regSubCommand(CorruptionTest.INSTANCE);
|
||||
// regSubCommand(PerformanceTest.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
//package net.momirealms.customcrops.command.subcmd;
|
||||
//
|
||||
//import net.momirealms.customcrops.CustomCrops;
|
||||
//import net.momirealms.customcrops.command.AbstractSubCommand;
|
||||
//import org.bukkit.Bukkit;
|
||||
//import org.bukkit.Location;
|
||||
//import org.bukkit.command.CommandSender;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class CorruptionTest extends AbstractSubCommand {
|
||||
//
|
||||
// public static final CorruptionTest INSTANCE = new CorruptionTest();
|
||||
//
|
||||
// public CorruptionTest() {
|
||||
// super("test");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean onCommand(CommandSender sender, List<String> args) {
|
||||
// Location location = new Location(Bukkit.getWorld("world"), 1604, 100, 1604);
|
||||
// for (int i = 0; i < 8; i++) {
|
||||
// for (int j = 0; j < 8; j++) {
|
||||
// Location newLoc = location.clone().add(i, 0, j);
|
||||
// Thread t1 = new Thread(() -> CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
// CustomCrops.getInstance().getPlatformInterface().placeNoteBlock(newLoc, "customcrops:wet_pot");
|
||||
// return null;
|
||||
// }));
|
||||
// Thread t2 = new Thread(() -> CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
// CustomCrops.getInstance().getPlatformInterface().placeNoteBlock(newLoc, "customcrops:dry_pot");
|
||||
// return null;
|
||||
// }));
|
||||
// Thread t3 = new Thread(() -> CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
// CustomCrops.getInstance().getPlatformInterface().removeAnyBlock(newLoc);
|
||||
// return null;
|
||||
// }));
|
||||
// t1.start();
|
||||
// t2.start();
|
||||
// t3.start();
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//}
|
||||
@@ -39,6 +39,8 @@ import net.momirealms.customcrops.integration.skill.MMOCoreImpl;
|
||||
import net.momirealms.customcrops.integration.skill.mcMMOImpl;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -113,8 +115,12 @@ public class IntegrationManager extends Function {
|
||||
}
|
||||
|
||||
private void hookJobs() {
|
||||
if (this.jobInterface instanceof JobsRebornImpl jobsReborn) {
|
||||
HandlerList.unregisterAll(jobsReborn);
|
||||
}
|
||||
if (pluginManager.isPluginEnabled("Jobs")) {
|
||||
this.jobInterface = new JobsRebornImpl();
|
||||
Bukkit.getPluginManager().registerEvents((Listener) jobInterface, plugin);
|
||||
hookMessage("JobsReborn");
|
||||
} else if (pluginManager.isPluginEnabled("EcoJobs")) {
|
||||
this.jobInterface = new EcoJobsImpl();
|
||||
|
||||
@@ -18,15 +18,17 @@
|
||||
package net.momirealms.customcrops.integration.job;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.*;
|
||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
import net.momirealms.customcrops.api.event.CropBreakEvent;
|
||||
import net.momirealms.customcrops.integration.JobInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JobsRebornImpl implements JobInterface {
|
||||
public class JobsRebornImpl implements JobInterface, Listener {
|
||||
|
||||
@Override
|
||||
public void addXp(Player player, double amount) {
|
||||
@@ -57,4 +59,39 @@ public class JobsRebornImpl implements JobInterface {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHarvest(CropBreakEvent event) {
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) return;
|
||||
if (!(event.getEntity() instanceof Player player)) return;
|
||||
|
||||
// check if in creative
|
||||
if (!JobsPaymentListener.payIfCreative(player))
|
||||
return;
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
JobsPlayer jobsPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jobsPlayer == null) return;
|
||||
|
||||
Jobs.action(jobsPlayer, new CustomCropsInfo(event.getCropItemID(), ActionType.MMKILL));
|
||||
}
|
||||
|
||||
public static class CustomCropsInfo extends BaseActionInfo {
|
||||
private final String name;
|
||||
|
||||
public CustomCropsInfo(String name, ActionType type) {
|
||||
super(type);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getNameWithSub() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user