Skip to content
This repository has been archived by the owner on May 29, 2022. It is now read-only.

Commit

Permalink
Knockback improve (#242)
Browse files Browse the repository at this point in the history
* Implement Knockback Profile

* Update EntityLiving.java

* Add knockback values

* New KnockbackCommand

* Patch stupid error

* Instant interactions

* Save knockback method

* FastMath cos/sin > MathHelper

Co-authored-by: Elier <[email protected]>

* Move ClickableBuilder to CobbleSword

* Update EntityHuman.java

* Update EntityHuman.java

* Change Knockback config to static

* fix conflict

* Update NachoSpigot-Server/src/main/java/net/minecraft/server/EntityHuman.java

Co-authored-by: Elier <[email protected]>

* Fix import

* Fix velocity variable not existing

* Save on Set

Co-authored-by: Sculas <[email protected]>
Co-authored-by: Elier <[email protected]>
  • Loading branch information
3 people authored Nov 14, 2021
1 parent 1bd45b3 commit 98268b2
Show file tree
Hide file tree
Showing 25 changed files with 1,230 additions and 352 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package dev.cobblesword.nachospigot.knockback;

public interface KnockbackProfile {

void save();
void save(boolean projectiles);

String getName();

void setName(String name);

double getHorizontal();

void setHorizontal(double horizontal);

double getVertical();

void setVertical(double vertical);

double getVerticalMin();

void setVerticalMin(double verticalMin);

double getVerticalMax();

void setVerticalMax(double verticalMax);

double getExtraHorizontal();

void setExtraHorizontal(double extraHorizontal);

double getExtraVertical();

void setExtraVertical(double extraVertical);

double getFrictionHorizontal();

void setFrictionHorizontal(double frictionHorizontal);

double getFrictionVertical();

void setFrictionVertical(double frictionVertical);

boolean isStopSprint();

void setStopSprint(boolean stopSprint);

double getRodHorizontal();

void setRodHorizontal(double rodHorizontal);

double getRodVertical();

void setRodVertical(double rodVertical);

double getArrowHorizontal();

void setArrowHorizontal(double arrowHorizontal);

double getArrowVertical();

void setArrowVertical(double arrowVertical);

double getPearlHorizontal();

void setPearlHorizontal(double pearlHorizontal) ;

double getPearlVertical();

void setPearlVertical(double pearlVertical);

double getSnowballHorizontal();

void setSnowballHorizontal(double snowballHorizontal);

double getSnowballVertical();

void setSnowballVertical(double snowballVertical);

double getEggHorizontal();

void setEggHorizontal(double eggHorizontal);

double getEggVertical();

void setEggVertical(double eggVertical);

String[] getKnockbackValues();

String[] getProjectilesValues();
}
37 changes: 0 additions & 37 deletions NachoSpigot-API/src/main/java/org/bukkit/Bukkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -565,43 +565,6 @@ public static void reload() {
server.reload();
}

/**
* Reloads the knockback config.
*/
public static void reloadKB() {
server.reloadKB();
}

/**
* Checks if custom knockback is enabled.
*/
public static boolean customKnockback() {
return server.customKnockback();
}

public static void toggleKnockback(Boolean b) {
server.toggleKnockback(b);
}

public static void setKnockbackFriction(double d) {
server.setKnockbackFriction(d);
}
public static void setKnockbackHorizontal(double d) {
server.setKnockbackHorizontal(d);
}
public static void setKnockbackVertical(double d) {
server.setKnockbackVertical(d);
}
public static void setKnockbackVerticalLimit(double d) {
server.setKnockbackVerticalLimit(d);
}
public static void setKnockbackExtraHorizontal(double d) {
server.setKnockbackExtraHorizontal(d);
}
public static void setKnockbackExtraVertical(double d) {
server.setKnockbackExtraVertical(d);
}

/**
* Returns the primary logger associated with this server instance.
*
Expand Down
17 changes: 0 additions & 17 deletions NachoSpigot-API/src/main/java/org/bukkit/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -458,19 +458,6 @@ public interface Server extends PluginMessageRecipient {
*/
public void reload();

/**
* Reloads the knockback config.
*/
public void reloadKB();
public void toggleKnockback(Boolean b);

public void setKnockbackFriction(double d);
public void setKnockbackHorizontal(double d);
public void setKnockbackVertical(double d);
public void setKnockbackVerticalLimit(double d);
public void setKnockbackExtraHorizontal(double d);
public void setKnockbackExtraVertical(double d);

/**
* Returns the primary logger associated with this server instance.
*
Expand Down Expand Up @@ -976,10 +963,6 @@ default boolean pluginsCommandEnabled() {
*/
CommandMap getCommandMap();

/**
* Checks if custom knockback is enabled.
*/
boolean customKnockback();
// Paper end

public class Spigot
Expand Down

This file was deleted.

12 changes: 12 additions & 0 deletions NachoSpigot-API/src/main/java/org/bukkit/entity/LivingEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;
import java.util.Set;

import dev.cobblesword.nachospigot.knockback.KnockbackProfile;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
Expand Down Expand Up @@ -252,6 +253,17 @@ public interface LivingEntity extends Entity, Damageable, ProjectileSource {
*/
public void setNoDamageTicks(int ticks);

/**
* Gets the knockback profile of this player.
*/
KnockbackProfile getKnockbackProfile();

/**
* Sets the knockback profile of this player. The player's knockback
* profile overrides the global knockback profile.
*/
void setKnockbackProfile(KnockbackProfile profile);

/**
* Gets the player identified as the killer of the living entity.
* <p>
Expand Down
5 changes: 5 additions & 0 deletions NachoSpigot-Server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.jafama</groupId>
<artifactId>jafama</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>net.sf.jopt-simple</groupId>
<artifactId>jopt-simple</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package dev.cobblesword.nachospigot;

import dev.cobblesword.nachospigot.knockback.KnockbackCommand;
import dev.cobblesword.nachospigot.knockback.KnockbackConfig;
import me.elier.nachospigot.config.NachoConfig;
import xyz.sculas.nacho.anticrash.AntiCrash;
import xyz.sculas.nacho.async.AsyncExplosions;
Expand Down Expand Up @@ -39,8 +41,10 @@ public static Nacho get() {
public void registerCommands() {
SetMaxSlotCommand setMaxSlotCommand = new SetMaxSlotCommand("sms"); //[Nacho-0021] Add setMaxPlayers within Bukkit.getServer() and SetMaxSlot Command
SpawnMobCommand spawnMobCommand = new SpawnMobCommand("spawnmob");
KnockbackCommand knockbackCommand = new KnockbackCommand("kb");
MinecraftServer.getServer().server.getCommandMap().register(setMaxSlotCommand.getName(), "ns", setMaxSlotCommand);
MinecraftServer.getServer().server.getCommandMap().register(spawnMobCommand.getName(), "ns", spawnMobCommand);
MinecraftServer.getServer().server.getCommandMap().register(knockbackCommand.getName(), "ns", knockbackCommand);
}

public void registerPacketListener(PacketListener packetListener) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package dev.cobblesword.nachospigot.commons;

import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;

public class ClickableBuilder {
private TextComponent textComponent;

public ClickableBuilder() { }

public ClickableBuilder(String message) {
this.textComponent = new TextComponent(message);
}

public ClickableBuilder setHover(String hover) {
this.textComponent.setHoverEvent(
new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hover).create())
);
return this;
}

public ClickableBuilder setClick(String command, ClickEvent.Action mode) {
this.textComponent.setClickEvent(new ClickEvent(mode, command));
return this;
}

public TextComponent build() {
return this.textComponent;
}
}
Loading

0 comments on commit 98268b2

Please sign in to comment.