Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakllp committed Dec 22, 2023
2 parents 5b329f8 + 2822682 commit 02b7caf
Show file tree
Hide file tree
Showing 146 changed files with 20,562 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ public class MyPetExpEvent extends Event implements Cancellable {
private final MyPet myPet;
private boolean isCancelled = false;
private double exp;
private boolean quiet;

public MyPetExpEvent(MyPet myPet, double exp) {
public MyPetExpEvent(MyPet myPet, double exp, boolean quiet) {
this.myPet = myPet;
this.exp = exp;
this.quiet = quiet;
}

public MyPetExpEvent(MyPet myPet, double exp) {
this(myPet, exp, false);
}

public MyPetPlayer getOwner() {
Expand All @@ -59,6 +65,10 @@ public double getExp() {
return exp;
}

public boolean isQuiet() {
return quiet;
}

public boolean isCancelled() {
return isCancelled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public double setMaxLevel(int level) {

public double setExp(double exp) {
exp = exp - this.exp;
return uppdateExp(exp, true);
return updateExp(exp, true);
}

public double addExp(double exp) {
Expand All @@ -104,7 +104,7 @@ public double addExp(double exp, boolean modify) {
if (modify) {
exp = modifyExp(exp);
}
return uppdateExp(exp, false);
return updateExp(exp, false);
}

public double addExp(Entity entity) {
Expand All @@ -118,7 +118,7 @@ public double addExp(Entity entity, boolean modify) {
if (modify) {
exp = modifyExp(exp);
}
return uppdateExp(exp, false);
return updateExp(exp, false);
}
return 0;
}
Expand All @@ -135,7 +135,7 @@ public double addExp(Entity entity, int percent, boolean modify) {
exp = modifyExp(exp);
}
exp = exp * percent / 100.;
return uppdateExp(exp, false);
return updateExp(exp, false);
}
return 0;
}
Expand All @@ -144,16 +144,16 @@ public double removeCurrentExp(double exp) {
if (exp > getCurrentExp()) {
exp = getCurrentExp();
}
return uppdateExp(-exp, false);
return updateExp(-exp, false);
}

public double removeExp(double exp) {
exp = this.exp - exp < 0 ? this.exp : exp;
return uppdateExp(-exp, false);
return updateExp(-exp, false);
}

protected double uppdateExp(double exp, boolean quiet) {
MyPetExpEvent expEvent = new MyPetExpEvent(myPet, exp);
protected double updateExp(double exp, boolean quiet) {
MyPetExpEvent expEvent = new MyPetExpEvent(myPet, exp, quiet);
Bukkit.getServer().getPluginManager().callEvent(expEvent);
if (expEvent.isCancelled()) {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public enum Version {
v1_19_R2,
v1_19_R3,
v1_20_R1,
v1_20_R2
v1_20_R2,
v1_20_R3
}

Version toVersion;
Expand Down
2 changes: 1 addition & 1 deletion modules/MyPet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<minecraft.version>1.20</minecraft.version>
<bukkit.packets>v1_8_R3;v1_9_R2;v1_12_R1;v1_16_R1;v1_16_R3;v1_17_R1;v1_18_R1;v1_18_R2;v1_19_R1;v1_19_R2;v1_19_R3;v1_20_R1;v1_20_R2</bukkit.packets>
<bukkit.packets>v1_8_R3;v1_9_R2;v1_12_R1;v1_16_R1;v1_16_R3;v1_17_R1;v1_18_R1;v1_18_R2;v1_19_R1;v1_19_R2;v1_19_R3;v1_20_R1;v1_20_R2;v1_20_R3</bukkit.packets>
<special.versions>1.19.2</special.versions>
</properties>

Expand Down
11 changes: 11 additions & 0 deletions modules/Plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,17 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>de.keyle</groupId>
<artifactId>mypet-compat-v1_20_R3</artifactId>
<version>1</version>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>de.keyle</groupId>
Expand Down
133 changes: 133 additions & 0 deletions modules/v1_20_R3/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>mypet-parent</artifactId>
<groupId>de.keyle</groupId>
<version>1</version>
<relativePath>../../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>mypet-compat-v1_20_R3</artifactId>
<version>1</version>
<packaging>jar</packaging>
<name>MyPet-v1_20_R3</name>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>brigadier</artifactId>
<version>1.0.18</version>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>datafixerupper</artifactId>
<version>4.0.26</version>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>javabridge</artifactId>
<version>1.2.24</version>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>3.2.38</version>
</dependency>

<dependency>
<groupId>de.keyle</groupId>
<artifactId>mypet-api</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>de.keyle</groupId>
<artifactId>mypet-skills</artifactId>
<version>1</version>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<finalName>${project.name}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.20.4-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.20.4-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* This file is part of MyPet
*
* Copyright © 2011-2020 Keyle
* MyPet is licensed under the GNU Lesser General Public License.
*
* MyPet 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
* (at your option) any later version.
*
* MyPet 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 <http://www.gnu.org/licenses/>.
*/

package de.Keyle.MyPet.compat.v1_20_R3;

import de.Keyle.MyPet.MyPetApi;
import de.Keyle.MyPet.api.util.Compat;
import de.Keyle.MyPet.api.util.ReflectionUtil;
import de.Keyle.MyPet.compat.v1_20_R3.services.EggIconService;
import de.Keyle.MyPet.compat.v1_20_R3.services.EntityConverterService;
import de.Keyle.MyPet.compat.v1_20_R3.services.RepositoryMyPetConverterService;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;

import java.lang.reflect.Method;

@Compat("v1_20_R3")
public class CompatManager extends de.Keyle.MyPet.api.util.CompatManager implements Listener {

public static Method ENTITY_LIVING_broadcastItemBreak = ReflectionUtil.getMethod(LivingEntity.class, "d", InteractionHand.class);

@Override
public void init() {
MyPetApi.getServiceManager().registerService(EggIconService.class);
MyPetApi.getServiceManager().registerService(EntityConverterService.class);
MyPetApi.getServiceManager().registerService(RepositoryMyPetConverterService.class);
}

@Override
public void enable() {
Bukkit.getServer().getPluginManager().registerEvents(this, MyPetApi.getPlugin());
}
}
Loading

0 comments on commit 02b7caf

Please sign in to comment.