mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-25 18:09:28 +00:00
2.2.9.1
This commit is contained in:
@@ -40,6 +40,7 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public final class CustomCrops extends JavaPlugin {
|
||||
|
||||
@@ -74,8 +75,10 @@ public final class CustomCrops extends JavaPlugin {
|
||||
@Override
|
||||
public void onLoad(){
|
||||
plugin = this;
|
||||
LibraryLoader.load("dev.dejvokep","boosted-yaml","1.3","https://repo.maven.apache.org/maven2/");
|
||||
LibraryLoader.load("commons-io","commons-io","2.11.0","https://repo.maven.apache.org/maven2/");
|
||||
TimeZone timeZone = TimeZone.getDefault();
|
||||
String libRepo = timeZone.getID().startsWith("Asia") ? "https://maven.aliyun.com/repository/public/" : "https://repo.maven.apache.org/maven2/";
|
||||
LibraryLoader.load("dev.dejvokep","boosted-yaml","1.3",libRepo);
|
||||
LibraryLoader.load("commons-io","commons-io","2.11.0",libRepo);
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
WorldGuardHook.initialize();
|
||||
}
|
||||
|
||||
@@ -369,26 +369,44 @@ public class MainConfig {
|
||||
|
||||
if (config.getBoolean("integration.AureliumSkills")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("AureliumSkills") == null) Log.warn("Failed to initialize AureliumSkills!");
|
||||
else skillInterface = new AureliumsHook();
|
||||
else {
|
||||
skillInterface = new AureliumsHook();
|
||||
hookMessage("AureliumSkills");
|
||||
}
|
||||
}
|
||||
if (config.getBoolean("integration.mcMMO")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("mcMMO") == null) Log.warn("Failed to initialize mcMMO!");
|
||||
else skillInterface = new mcMMOHook();
|
||||
else {
|
||||
skillInterface = new mcMMOHook();
|
||||
hookMessage("mcMMO");
|
||||
}
|
||||
}
|
||||
if (config.getBoolean("integration.MMOCore")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("MMOCore") == null) Log.warn("Failed to initialize MMOCore!");
|
||||
else skillInterface = new MMOCoreHook();
|
||||
else {
|
||||
skillInterface = new MMOCoreHook();
|
||||
hookMessage("MMOCore");
|
||||
}
|
||||
}
|
||||
if (config.getBoolean("integration.EcoSkills")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("EcoSkills") == null) Log.warn("Failed to initialize EcoSkills!");
|
||||
else skillInterface = new EcoSkillsHook();
|
||||
else {
|
||||
skillInterface = new EcoSkillsHook();
|
||||
hookMessage("EcoSkills");
|
||||
}
|
||||
}
|
||||
if (config.getBoolean("integration.JobsReborn")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("Jobs") == null) Log.warn("Failed to initialize JobsReborn!");
|
||||
else jobInterface = new JobsRebornHook();
|
||||
else {
|
||||
jobInterface = new JobsRebornHook();
|
||||
hookMessage("JobsReborn");
|
||||
}
|
||||
} else if (config.getBoolean("integration.EcoJobs")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("EcoJobs") == null) Log.warn("Failed to initialize EcoJobs!");
|
||||
else jobInterface = new EcoJobsHook();
|
||||
else {
|
||||
jobInterface = new EcoJobsHook();
|
||||
hookMessage("EcoJobs");
|
||||
}
|
||||
}
|
||||
|
||||
realisticSeasonHook = false;
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
@@ -209,7 +210,8 @@ public class OraxenFrameHandler extends OraxenHandler {
|
||||
if (id == null) return;
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final ItemFrame itemFrame = event.getItemFrame();
|
||||
final Entity entity = event.getBaseEntity();
|
||||
if (!(entity instanceof ItemFrame itemFrame)) return;
|
||||
final Location location = itemFrame.getLocation();
|
||||
|
||||
Sprinkler sprinkler = SprinklerConfig.SPRINKLERS_3D.get(id);
|
||||
|
||||
@@ -79,7 +79,7 @@ public abstract class OraxenHandler extends HandlerP {
|
||||
FurnitureMechanic mechanic = event.getMechanic();
|
||||
String id = mechanic.getItemID();
|
||||
if (!id.equals(BasicItemConfig.scarecrow)) return;
|
||||
Location location = event.getItemFrame().getLocation();
|
||||
Location location = event.getBaseEntity().getLocation();
|
||||
CustomWorld customWorld = cropManager.getCustomWorld(location.getWorld());
|
||||
if (customWorld == null) return;
|
||||
customWorld.addScarecrowCache(location);
|
||||
|
||||
@@ -95,7 +95,7 @@ public class OraxenHook implements CustomInterface {
|
||||
@Nullable
|
||||
public ItemFrame placeFurniture(Location location, String id) {
|
||||
FurnitureMechanic mechanic = (FurnitureMechanic) FurnitureFactory.getInstance().getMechanic(id);
|
||||
return mechanic.place(Rotation.NONE, 0, BlockFace.UP, location);
|
||||
return (ItemFrame) mechanic.place(location, 0, Rotation.NONE, BlockFace.UP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -114,7 +114,7 @@ public class OraxenWireHandler extends OraxenHandler{
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final Location blockLoc = event.getItemFrame().getLocation();
|
||||
final Location blockLoc = event.getBaseEntity().getLocation();
|
||||
|
||||
if (!CCAntiGrief.testPlace(player, blockLoc)) return;
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class CustomWorld {
|
||||
|
||||
@@ -361,7 +362,7 @@ public class CustomWorld {
|
||||
|
||||
public void growWire(int cropTime, int sprinklerTime, int dryTime, boolean compensation, boolean force) {
|
||||
if (cropData == null) return;
|
||||
Random randomGenerator = new Random();
|
||||
Random randomGenerator = ThreadLocalRandom.current();
|
||||
if (force) {
|
||||
for (SimpleLocation location : cropData.keySet()) {
|
||||
growSingleWire(location, randomGenerator.nextInt(cropTime));
|
||||
@@ -402,7 +403,7 @@ public class CustomWorld {
|
||||
|
||||
public void growFrame(int cropTime, int sprinklerTime, int dryTime, boolean compensation, boolean force) {
|
||||
if (cropData == null) return;
|
||||
Random randomGenerator = new Random();
|
||||
Random randomGenerator = ThreadLocalRandom.current();
|
||||
if (force) {
|
||||
for (SimpleLocation location : cropData.keySet()) {
|
||||
growSingleFrame(location, randomGenerator.nextInt(cropTime));
|
||||
@@ -456,7 +457,7 @@ public class CustomWorld {
|
||||
plantedToday.clear();;
|
||||
|
||||
//洒水器工作会把种植盆放入watered中
|
||||
Random randomGenerator = new Random();
|
||||
Random randomGenerator = ThreadLocalRandom.current();
|
||||
for (Map.Entry<SimpleLocation, Sprinkler> sprinklerEntry : sprinklerCache.entrySet()) {
|
||||
bukkitScheduler.runTaskLaterAsynchronously(CustomCrops.plugin, () -> sprinklerWork(sprinklerEntry.getKey(), sprinklerEntry.getValue()), randomGenerator.nextInt(sprinklerTime));
|
||||
}
|
||||
@@ -515,7 +516,7 @@ public class CustomWorld {
|
||||
cropManager.makePotDry(potLoc);
|
||||
}
|
||||
}
|
||||
}.runTaskLaterAsynchronously(CustomCrops.plugin, new Random().nextInt(dry_time));
|
||||
}.runTaskLaterAsynchronously(CustomCrops.plugin, ThreadLocalRandom.current().nextInt(dry_time));
|
||||
}
|
||||
//用完就抛弃
|
||||
tempWatered.clear();
|
||||
@@ -555,8 +556,8 @@ public class CustomWorld {
|
||||
double chance = (double) (24000 - world.getTime()) / 24000;
|
||||
plantedToday.add(simpleLocation);
|
||||
if (Math.random() > chance) return;
|
||||
if (MainConfig.cropMode) growSingleWire(simpleLocation, new Random().nextInt(delay));
|
||||
else growSingleFrame(simpleLocation, new Random().nextInt(delay));
|
||||
if (MainConfig.cropMode) growSingleWire(simpleLocation, ThreadLocalRandom.current().nextInt(delay));
|
||||
else growSingleFrame(simpleLocation, ThreadLocalRandom.current().nextInt(delay));
|
||||
}
|
||||
}
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user