mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 05:55:27 +01:00
Cleanup
This commit is contained in:
parent
0a46298b7d
commit
cb5337f6f6
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/mypet-3.12.jar
Normal file
BIN
libs/mypet-3.12.jar
Normal file
Binary file not shown.
113
pom.xml
113
pom.xml
@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>Jobs</groupId>
|
||||
<artifactId>jobs</artifactId>
|
||||
<version>5.2.2.5</version>
|
||||
<version>5.2.3.0</version>
|
||||
<name>Jobs</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
@ -17,32 +17,16 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.20.6-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.20.6-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mojang</groupId>
|
||||
@ -54,9 +38,7 @@
|
||||
<dependency>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.175-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/libs/mcMMO-2.1.175-SNAPSHOT.jar</systemPath>
|
||||
<version>2.2.004</version>
|
||||
</dependency>
|
||||
<!-- Vault -->
|
||||
<dependency>
|
||||
@ -76,38 +58,12 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- MythicMobs -->
|
||||
<dependency>
|
||||
<groupId>io.lumine.xikage</groupId>
|
||||
<artifactId>MythicMobs</artifactId>
|
||||
<version>4.11.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.lumine</groupId>
|
||||
<artifactId>Mythic-Dist</artifactId>
|
||||
<version>5.1.0-SNAPSHOT</version>
|
||||
<version>5.6.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- WorldGuard old version -->
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>commandbook</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q.spigot</groupId>
|
||||
<artifactId>bukkit-classloader-check</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- WorldGuard new version -->
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
@ -195,27 +151,21 @@
|
||||
</dependency>
|
||||
<!-- CMILib -->
|
||||
<dependency>
|
||||
<groupId>net.Zrips</groupId>
|
||||
<groupId>com.github.Zrips</groupId>
|
||||
<artifactId>CMILib</artifactId>
|
||||
<version>latest</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/libs/CMILib1.4.6.2.jar</systemPath>
|
||||
<version>1.4.7.4</version>
|
||||
</dependency>
|
||||
<!-- WildStacker -->
|
||||
<dependency>
|
||||
<groupId>com.bgsoftware</groupId>
|
||||
<artifactId>WildStackerAPI</artifactId>
|
||||
<version>latest</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/libs/WildStackerAPI-2023.2.jar</systemPath>
|
||||
<version>3.8.0</version>
|
||||
</dependency>
|
||||
<!-- StackMob -->
|
||||
<dependency>
|
||||
<groupId>com.github.Nathat23</groupId>
|
||||
<artifactId>StackMob-5</artifactId>
|
||||
<version>5.5.3</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/libs/StackMob-5.5.3.jar</systemPath>
|
||||
<groupId>uk.antiperson.stackmob</groupId>
|
||||
<artifactId>StackMob</artifactId>
|
||||
<version>5.8.2</version>
|
||||
</dependency>
|
||||
<!-- MyPet -->
|
||||
<dependency>
|
||||
@ -224,10 +174,14 @@
|
||||
<version>3.11-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<!-- Temporary solution for replacing repository -->
|
||||
<systemPath>${basedir}/libs/mypet-3.11-20210318.180552-1.jar</systemPath>
|
||||
<systemPath>${basedir}/libs/mypet-3.12.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>CodeMC</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
<!-- MythicMobs -->
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
@ -243,14 +197,13 @@
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<!-- papermc -->
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
<id>neetgames</id>
|
||||
<url>https://nexus.neetgames.com/repository/maven-releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>minecraft-repo</id>
|
||||
<url>https://libraries.minecraft.net/</url>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<!-- PlaceholderAPI -->
|
||||
<repository>
|
||||
@ -258,6 +211,10 @@
|
||||
<url>
|
||||
https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bg-repo</id>
|
||||
<url>https://repo.bg-software.com/repository/api/</url>
|
||||
</repository>
|
||||
<!-- MyPet -->
|
||||
<!--<repository> <id>mypet-repo</id> <url>https://repo.mypet-plugin.de/</url>
|
||||
</repositor> -->
|
||||
@ -283,14 +240,6 @@
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<outputDirectory>D:/MC/Server 1.20/plugins</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -108,7 +108,6 @@ import com.gamingmesh.jobs.stuff.Util;
|
||||
import com.gamingmesh.jobs.stuff.VersionChecker;
|
||||
import com.gamingmesh.jobs.stuff.complement.Complement;
|
||||
import com.gamingmesh.jobs.stuff.complement.Complement1;
|
||||
import com.gamingmesh.jobs.stuff.complement.Complement2;
|
||||
import com.gamingmesh.jobs.stuff.complement.JobsChatEvent;
|
||||
import com.gamingmesh.jobs.tasks.BufferedPaymentThread;
|
||||
import com.gamingmesh.jobs.tasks.DatabaseSaveThread;
|
||||
@ -766,12 +765,7 @@ public final class Jobs extends JavaPlugin {
|
||||
HookManager.loadHooks();
|
||||
registerListeners();
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_16_R3) && kyoriSupported) {
|
||||
complement = new Complement2();
|
||||
//getServer().getPluginManager().registerEvents(new KyoriChatEvent(this), this);
|
||||
} else {
|
||||
complement = new Complement1();
|
||||
}
|
||||
complement = new Complement1();
|
||||
|
||||
if (HookVault.isVaultEnable()) {
|
||||
// register economy
|
||||
|
@ -36,7 +36,6 @@ import net.Zrips.CMILib.Items.CMIAsyncHead;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Locale.LC;
|
||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
||||
import net.Zrips.CMILib.Messages.CMIMessages;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -518,14 +517,14 @@ public class ShopManager {
|
||||
|
||||
String potionData = "";
|
||||
if (itemSection.contains("potion-type")) {
|
||||
PotionType type;
|
||||
PotionType type = null;
|
||||
try {
|
||||
type = PotionType.valueOf(itemSection.getString("potion-type", "speed").toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
type = PotionType.SPEED;
|
||||
}
|
||||
|
||||
potionData += type.toString() + ":false:false";
|
||||
if (type != null)
|
||||
potionData += type.toString() + ":false:false";
|
||||
}
|
||||
|
||||
String itemSring = mat.toString();
|
||||
|
@ -9,7 +9,6 @@ import com.gamingmesh.jobs.hooks.McMMO.McMMO2_X_listener;
|
||||
import com.gamingmesh.jobs.hooks.McMMO.McMMOManager;
|
||||
import com.gamingmesh.jobs.hooks.MyPet.MyPetManager;
|
||||
import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobInterface;
|
||||
import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobs4;
|
||||
import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobs5;
|
||||
import com.gamingmesh.jobs.hooks.WorldGuard.WorldGuardManager;
|
||||
import com.gamingmesh.jobs.hooks.stackMob.StackMobHandler;
|
||||
@ -31,118 +30,112 @@ public class HookManager {
|
||||
private static PluginManager pm;
|
||||
|
||||
public static void loadHooks() {
|
||||
pm = PLUGIN.getServer().getPluginManager();
|
||||
pm = PLUGIN.getServer().getPluginManager();
|
||||
|
||||
setMyPetManager();
|
||||
setWorldGuard();
|
||||
setMythicManager();
|
||||
setStackMobHandler();
|
||||
setWildStackerHandler();
|
||||
setMyPetManager();
|
||||
setWorldGuard();
|
||||
setMythicManager();
|
||||
setStackMobHandler();
|
||||
setWildStackerHandler();
|
||||
}
|
||||
|
||||
public static StackMobHandler getStackMobHandler() {
|
||||
if (stackMobHandler == null) {
|
||||
setStackMobHandler();
|
||||
}
|
||||
if (stackMobHandler == null) {
|
||||
setStackMobHandler();
|
||||
}
|
||||
|
||||
return stackMobHandler;
|
||||
return stackMobHandler;
|
||||
}
|
||||
|
||||
public static WildStackerHandler getWildStackerHandler() {
|
||||
if (wildStackerHandler == null) {
|
||||
setWildStackerHandler();
|
||||
}
|
||||
if (wildStackerHandler == null) {
|
||||
setWildStackerHandler();
|
||||
}
|
||||
|
||||
return wildStackerHandler;
|
||||
return wildStackerHandler;
|
||||
}
|
||||
|
||||
public static MyPetManager getMyPetManager() {
|
||||
if (myPetManager == null) {
|
||||
setMyPetManager();
|
||||
}
|
||||
if (myPetManager == null) {
|
||||
setMyPetManager();
|
||||
}
|
||||
|
||||
return myPetManager;
|
||||
return myPetManager;
|
||||
}
|
||||
|
||||
public static WorldGuardManager getWorldGuardManager() {
|
||||
if (worldGuardManager == null) {
|
||||
worldGuardManager = new WorldGuardManager();
|
||||
}
|
||||
if (worldGuardManager == null) {
|
||||
worldGuardManager = new WorldGuardManager();
|
||||
}
|
||||
|
||||
return worldGuardManager;
|
||||
return worldGuardManager;
|
||||
}
|
||||
|
||||
public static McMMOManager getMcMMOManager() {
|
||||
if (McMMOManager == null)
|
||||
McMMOManager = new McMMOManager();
|
||||
if (McMMOManager == null)
|
||||
McMMOManager = new McMMOManager();
|
||||
|
||||
return McMMOManager;
|
||||
return McMMOManager;
|
||||
}
|
||||
|
||||
public static MythicMobInterface getMythicManager() {
|
||||
return MythicManager;
|
||||
return MythicManager;
|
||||
}
|
||||
|
||||
public static boolean checkMythicMobs() {
|
||||
return Jobs.getGCManager().MythicMobsEnabled && MythicManager != null && MythicManager.check();
|
||||
return Jobs.getGCManager().MythicMobsEnabled && MythicManager != null && MythicManager.check();
|
||||
}
|
||||
|
||||
private static boolean setWorldGuard() {
|
||||
if (JobsHook.WorldGuard.isEnabled()) {
|
||||
worldGuardManager = new WorldGuardManager();
|
||||
CMIMessages.consoleMessage("&eWorldGuard detected.");
|
||||
return true;
|
||||
}
|
||||
if (JobsHook.WorldGuard.isEnabled()) {
|
||||
worldGuardManager = new WorldGuardManager();
|
||||
CMIMessages.consoleMessage("&eWorldGuard detected.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void setMythicManager() {
|
||||
if (!JobsHook.MythicMobs.isPresent())
|
||||
return;
|
||||
if (!JobsHook.MythicMobs.isPresent())
|
||||
return;
|
||||
|
||||
try {
|
||||
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper");
|
||||
MythicManager = new MythicMobs4(PLUGIN);
|
||||
CMIMessages.consoleMessage("&eMythicMobs 4.x detected.");
|
||||
} catch (ClassNotFoundException ex) {
|
||||
try {
|
||||
Class.forName("io.lumine.mythic.bukkit.BukkitAPIHelper");
|
||||
MythicManager = new MythicMobs5(PLUGIN);
|
||||
CMIMessages.consoleMessage("&eMythicMobs 5.x detected.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
CMIMessages.consoleMessage("&cYour MythicMobs version is not supported by Jobs! Supported versions: 4.9.1+");
|
||||
}
|
||||
}
|
||||
try {
|
||||
Class.forName("io.lumine.mythic.bukkit.BukkitAPIHelper");
|
||||
MythicManager = new MythicMobs5(PLUGIN);
|
||||
CMIMessages.consoleMessage("&eMythicMobs 5.x detected.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
CMIMessages.consoleMessage("&cYour MythicMobs version is not supported by Jobs! Supported versions: 4.9.1+");
|
||||
}
|
||||
}
|
||||
|
||||
public static void setMcMMOlistener() {
|
||||
try {
|
||||
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
|
||||
pm.registerEvents(new McMMO2_X_listener(), PLUGIN);
|
||||
CMIMessages.consoleMessage("&eRegistered McMMO 2.x listener");
|
||||
} catch (ClassNotFoundException e) {
|
||||
pm.registerEvents(new McMMO1_X_listener(), PLUGIN);
|
||||
CMIMessages.consoleMessage("&eRegistered McMMO 1.x listener");
|
||||
}
|
||||
try {
|
||||
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
|
||||
pm.registerEvents(new McMMO2_X_listener(), PLUGIN);
|
||||
CMIMessages.consoleMessage("&eRegistered McMMO 2.x listener");
|
||||
} catch (ClassNotFoundException e) {
|
||||
pm.registerEvents(new McMMO1_X_listener(), PLUGIN);
|
||||
CMIMessages.consoleMessage("&eRegistered McMMO 1.x listener");
|
||||
}
|
||||
}
|
||||
|
||||
private static void setMyPetManager() {
|
||||
if (JobsHook.MyPet.isEnabled()) {
|
||||
myPetManager = new MyPetManager();
|
||||
CMIMessages.consoleMessage("&eMyPet detected.");
|
||||
}
|
||||
if (JobsHook.MyPet.isEnabled()) {
|
||||
myPetManager = new MyPetManager();
|
||||
CMIMessages.consoleMessage("&eMyPet detected.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void setStackMobHandler() {
|
||||
if (JobsHook.StackMob.isEnabled()) {
|
||||
stackMobHandler = new StackMobHandler();
|
||||
}
|
||||
if (JobsHook.StackMob.isEnabled()) {
|
||||
stackMobHandler = new StackMobHandler();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setWildStackerHandler() {
|
||||
if (JobsHook.WildStacker.isEnabled()) {
|
||||
wildStackerHandler = new WildStackerHandler();
|
||||
}
|
||||
if (JobsHook.WildStacker.isEnabled()) {
|
||||
wildStackerHandler = new WildStackerHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,75 +0,0 @@
|
||||
package com.gamingmesh.jobs.hooks.MythicMobs;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.MythicMobs;
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper;
|
||||
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
|
||||
import net.Zrips.CMILib.Messages.CMIMessages;
|
||||
|
||||
public class MythicMobs4 implements MythicMobInterface {
|
||||
|
||||
public BukkitAPIHelper apiHelper;
|
||||
private Jobs plugin;
|
||||
|
||||
public MythicMobs4(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerListener() {
|
||||
plugin.getServer().getPluginManager().registerEvents(new MythicMobs4Listener(), plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMythicMob(LivingEntity lVictim) {
|
||||
return apiHelper != null && lVictim != null && apiHelper.isMythicMob(lVictim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check() {
|
||||
Plugin mm = plugin.getServer().getPluginManager().getPlugin("MythicMobs");
|
||||
if (mm == null)
|
||||
return false;
|
||||
|
||||
try {
|
||||
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent");
|
||||
Class.forName("io.lumine.xikage.mythicmobs.mobs.MythicMob");
|
||||
Class.forName("io.lumine.xikage.mythicmobs.MythicMobs");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Disabling
|
||||
CMIMessages.consoleMessage("&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support.");
|
||||
return false;
|
||||
}
|
||||
|
||||
apiHelper = ((MythicMobs) mm).getAPIHelper();
|
||||
CMIMessages.consoleMessage("&e[Jobs] &6MythicMobs was found - Enabling capabilities.");
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean failed = false;
|
||||
|
||||
@Override
|
||||
public String getDisplayName(String id) {
|
||||
if (failed || apiHelper == null)
|
||||
return "";
|
||||
|
||||
MythicMob mm = apiHelper.getMythicMob(id);
|
||||
try {
|
||||
if (mm != null && mm.getDisplayName() != null)
|
||||
return mm.getDisplayName().toString();
|
||||
} catch (Throwable e) {
|
||||
if (!failed) {
|
||||
failed = true;
|
||||
e.printStackTrace();
|
||||
CMIMessages.consoleMessage("&cEncountered error when checking MythicMob entity name. Support for mythicMobs will be suspended for time beying. Please report this issue.");
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package com.gamingmesh.jobs.hooks.MythicMobs;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.actions.MMKillInfo;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
|
||||
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
|
||||
|
||||
public final class MythicMobs4Listener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onMythicMobDeath(MythicMobDeathEvent event) {
|
||||
// Entity that died must be living
|
||||
if (!(event.getEntity() instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
Player pDamager = null;
|
||||
|
||||
// Checking if killer is player
|
||||
Entity ent = null;
|
||||
if (event.getKiller() instanceof Player)
|
||||
pDamager = (Player) event.getKiller();
|
||||
// Checking if killer is tamed animal
|
||||
else if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
|
||||
ent = ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager();
|
||||
} else
|
||||
return;
|
||||
|
||||
if (pDamager == null)
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (!JobsPaymentListener.payIfCreative(pDamager))
|
||||
return;
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
|
||||
if (jDamager == null)
|
||||
return;
|
||||
|
||||
// pay
|
||||
MythicMob lVictim = event.getMobType();
|
||||
if (lVictim != null) {
|
||||
Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), ent);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@ import com.gamingmesh.jobs.container.RestrictedArea;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
@ -23,109 +22,70 @@ import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
public class WorldGuardManager {
|
||||
|
||||
private WorldGuardPlugin wg;
|
||||
private boolean useOld = false;
|
||||
|
||||
public WorldGuardManager() {
|
||||
Plugin pl = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
if (pl instanceof WorldGuardPlugin) {
|
||||
wg = (WorldGuardPlugin) pl;
|
||||
|
||||
if (pl.getDescription().getVersion().equals("6.1")) {
|
||||
useOld = true;
|
||||
}
|
||||
}
|
||||
Plugin pl = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
if (pl instanceof WorldGuardPlugin) {
|
||||
wg = (WorldGuardPlugin) pl;
|
||||
}
|
||||
}
|
||||
|
||||
public WorldGuardPlugin getPlugin() {
|
||||
return wg;
|
||||
return wg;
|
||||
}
|
||||
|
||||
public List<RestrictedArea> getArea(Location loc) {
|
||||
try {
|
||||
if (useOld) {
|
||||
RegionManager manager = wg.getRegionContainer().get(loc.getWorld());
|
||||
try {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
|
||||
|
||||
if (manager != null) {
|
||||
ApplicableRegionSet regions = manager.getApplicableRegions(loc);
|
||||
if (regions != null) {
|
||||
for (ProtectedRegion one : regions.getRegions().values()) {
|
||||
List<RestrictedArea> rest = Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
|
||||
|
||||
for (ProtectedRegion one : regions.getRegions()) {
|
||||
List<RestrictedArea> rest = Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
|
||||
if (!rest.isEmpty())
|
||||
return rest;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
if (!rest.isEmpty())
|
||||
return rest;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
|
||||
|
||||
if (regions != null) {
|
||||
for (ProtectedRegion one : regions.getRegions().values()) {
|
||||
List<RestrictedArea> rest = Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
|
||||
|
||||
if (!rest.isEmpty())
|
||||
return rest;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean inArea(Location loc, String name) {
|
||||
if (useOld) {
|
||||
RegionManager manager = wg.getRegionContainer().get(loc.getWorld());
|
||||
|
||||
if (manager != null) {
|
||||
ApplicableRegionSet regions = manager.getApplicableRegions(loc);
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
|
||||
|
||||
for (ProtectedRegion one : regions.getRegions()) {
|
||||
if (one.getId().equalsIgnoreCase(name) && one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
|
||||
if (regions != null) {
|
||||
for (ProtectedRegion one : regions.getRegions().values()) {
|
||||
if (one.getId().equalsIgnoreCase(name) && one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (regions != null) {
|
||||
for (ProtectedRegion one : regions.getRegions().values()) {
|
||||
if (one.getId().equalsIgnoreCase(name) && one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public ProtectedRegion getProtectedRegionByName(String name) {
|
||||
for (World one : Bukkit.getServer().getWorlds()) {
|
||||
Map<String, ProtectedRegion> regions = null;
|
||||
for (World one : Bukkit.getServer().getWorlds()) {
|
||||
Map<String, ProtectedRegion> regions = null;
|
||||
|
||||
if (useOld) {
|
||||
RegionManager manager = wg.getRegionContainer().get(one);
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionManager manager = container.get(BukkitAdapter.adapt(one));
|
||||
|
||||
if (manager != null)
|
||||
regions = manager.getRegions();
|
||||
} else {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionManager manager = container.get(BukkitAdapter.adapt(one));
|
||||
if (manager != null)
|
||||
regions = manager.getRegions();
|
||||
|
||||
if (manager != null)
|
||||
regions = manager.getRegions();
|
||||
}
|
||||
if (regions != null) {
|
||||
for (Entry<String, ProtectedRegion> map : regions.entrySet()) {
|
||||
if (map.getKey().equalsIgnoreCase(name))
|
||||
return map.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (regions != null) {
|
||||
for (Entry<String, ProtectedRegion> map : regions.entrySet()) {
|
||||
if (map.getKey().equalsIgnoreCase(name))
|
||||
return map.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
public void onCowMilking(PlayerInteractEntityEvent event) {
|
||||
Entity entity = event.getRightClicked();
|
||||
|
||||
CMIEntityType type = CMIEntityType.getByType(entity.getType());
|
||||
CMIEntityType type = CMIEntityType.get(entity.getType());
|
||||
|
||||
if (type != CMIEntityType.COW && type != CMIEntityType.MUSHROOM_COW && type != CMIEntityType.GOAT)
|
||||
return;
|
||||
@ -264,7 +264,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemInHand.getType() == Material.BOWL && entity.getType() != EntityType.MUSHROOM_COW) {
|
||||
if (itemInHand.getType() == Material.BOWL && type != CMIEntityType.MUSHROOM_COW) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1661,11 +1661,14 @@ public final class JobsPaymentListener implements Listener {
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(e))
|
||||
return;
|
||||
|
||||
EntityType type = event.getEntityType();
|
||||
if (type != EntityType.PRIMED_TNT && type != EntityType.MINECART_TNT && type != CMIEntityType.ENDER_CRYSTAL.getType())
|
||||
CMIEntityType type = CMIEntityType.get(event.getEntityType());
|
||||
|
||||
|
||||
|
||||
if (type != CMIEntityType.TNT && type != CMIEntityType.TNT_MINECART && type != CMIEntityType.ENDER_CRYSTAL)
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().isUseTntFinder() && type != CMIEntityType.ENDER_CRYSTAL.getType())
|
||||
if (!Jobs.getGCManager().isUseTntFinder() && type != CMIEntityType.ENDER_CRYSTAL)
|
||||
return;
|
||||
|
||||
double closest = 60.0;
|
||||
@ -1697,7 +1700,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().isUseTntFinder() && type == CMIEntityType.ENDER_CRYSTAL.getType()) {
|
||||
if (!Jobs.getGCManager().isUseTntFinder() && type == CMIEntityType.ENDER_CRYSTAL) {
|
||||
UUID eUUID = e.getUniqueId();
|
||||
Entity killed = punchedEndCrystals.getIfPresent(eUUID);
|
||||
|
||||
|
@ -1,47 +0,0 @@
|
||||
package com.gamingmesh.jobs.stuff.complement;
|
||||
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class Complement2 implements Complement {
|
||||
|
||||
protected String serialize(Component component) {
|
||||
return LegacyComponentSerializer.legacyAmpersand().serialize(component);
|
||||
}
|
||||
|
||||
protected TextComponent deserialize(String t) {
|
||||
return LegacyComponentSerializer.legacyAmpersand().deserialize(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLine(SignChangeEvent event, int line) {
|
||||
Component l = event.line(line);
|
||||
return l == null ? "" : serialize(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLine(SignChangeEvent event, int line, String text) {
|
||||
event.line(line, deserialize(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLine(Sign sign, int line) {
|
||||
return serialize(sign.line(line));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(Player player) {
|
||||
return serialize(player.displayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLine(Sign sign, int line, String text) {
|
||||
sign.line(line, deserialize(text));
|
||||
}
|
||||
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package com.gamingmesh.jobs.stuff.complement;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import io.papermc.paper.chat.ChatRenderer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
|
||||
public final class KyoriChatEvent extends Complement2 implements Listener {
|
||||
|
||||
private Jobs plugin;
|
||||
|
||||
public KyoriChatEvent(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void asyncChatEvent(final AsyncChatEvent event) {
|
||||
if (event.isCancelled() || Util.getJobsEditorMap().isEmpty())
|
||||
return;
|
||||
|
||||
final String msg = Util.getJobsEditorMap().remove(event.getPlayer().getUniqueId());
|
||||
if (msg != null) {
|
||||
CMIScheduler.get().runTask(() -> event.getPlayer().performCommand(msg + serialize(event.message())));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Adding to chat prefix job name
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerChat(AsyncChatEvent event) {
|
||||
if (!Jobs.getGCManager().getModifyChat())
|
||||
return;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
|
||||
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
|
||||
if (honorific.equals(" "))
|
||||
honorific = "";
|
||||
|
||||
// TODO displayName returns the player display name not the chat component from
|
||||
// chat plugins, like Essentials
|
||||
// Now there is a parameter "player", so literally we need to add 800+ chat plugins
|
||||
// to this plugin as dependency?
|
||||
// 3rd attempt: now we tried to use text replacement config builder to match the variable
|
||||
// result: instead of replacing the variable, now the chat message never been sent
|
||||
//event.composer((player, displayName, msg) -> msg
|
||||
//.replaceText(TextReplacementConfig.builder().match("{jobs}").once().replacement(h).build()));
|
||||
|
||||
event.message(ChatRenderer.defaultRenderer().render(event.getPlayer(), event.getPlayer().displayName(), event.message(), event.getPlayer()).replaceText(TextReplacementConfig.builder().match(
|
||||
"\\{jobs\\}").replacement(honorific).build()));
|
||||
// 4th attempt: composeChat -> doing nothing
|
||||
// event.message(ChatComposer.DEFAULT.composeChat(event.getPlayer(), event.getPlayer().displayName(), event.message())
|
||||
// .replaceText(TextReplacementConfig.builder().match("\\{jobs\\}").replacement(honorific).build()));
|
||||
}
|
||||
|
||||
// Changing chat prefix variable to job name
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerChatLow(AsyncChatEvent event) {
|
||||
onPlayerChatHigh(event);
|
||||
}
|
||||
|
||||
// Changing chat prefix variable to job name
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerChatHigh(AsyncChatEvent event) {
|
||||
if (Jobs.getGCManager().getModifyChat())
|
||||
return;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
|
||||
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
|
||||
if (honorific.equals(" "))
|
||||
honorific = "";
|
||||
|
||||
event.message(ChatRenderer.defaultRenderer().render(event.getPlayer(), event.getPlayer().displayName(), event.message(), event.getPlayer()).replaceText(TextReplacementConfig.builder().match(
|
||||
"\\{jobs\\}").replacement(honorific).build()));
|
||||
|
||||
// event.message(ChatComposer.DEFAULT
|
||||
// .composeChat(event.getPlayer(), event.getPlayer().displayName(), event.message())
|
||||
// .replaceText(TextReplacementConfig.builder().match("\\{jobs\\}").replacement(honorific).build()));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user