Skip to content

Commit

Permalink
Merge pull request #124 from VolmitSoftware/Development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NextdoorPsycho authored Sep 8, 2022
2 parents 796a7d1 + d000cc6 commit 93b9e9e
Show file tree
Hide file tree
Showing 12 changed files with 328 additions and 46 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
}


version '1.0.11-1.19.2' // Needs to be version specific
version '1.0.12-1.19.2' // Needs to be version specific
def nmsVersion = "1.19.2" //[NMS]
def apiVersion = '1.19'
def specialSourceVersion = '1.11.0' //[NMS]
Expand Down
73 changes: 73 additions & 0 deletions src/main/java/com/volmit/adapt/api/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.volmit.adapt.api.xp.XP;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
Expand Down Expand Up @@ -499,6 +500,78 @@ default void damageOffHand(Player p, int damage) {
p.getInventory().setItemInOffHand(is);
}

default Block getRightBlock(Player p, Block b) {
Location l = p.getLocation();
float yaw = l.getYaw();
// Make sure yaw is in the range 0 to 360
while (yaw < 0) {
yaw += 360;
}
yaw = yaw % 360;
// The player's yaw is their rotation in the world,
// so, we can use that to get the right face of a block!
BlockFace rightFace;
// if the player is facing SE to SW
if (yaw < 45 || yaw >= 315) {
rightFace = BlockFace.EAST;
return b.getRelative(rightFace);
}
// if the player is facing SW to NW
else if (yaw < 135) {
rightFace = BlockFace.SOUTH;
return b.getRelative(rightFace);
}
// if the player is facing NW to NE
else if (yaw < 225) {
rightFace = BlockFace.WEST;
return b.getRelative(rightFace);
}
// if the player is facing NE to SE
else if (yaw < 315) {
rightFace = BlockFace.NORTH;
return b.getRelative(rightFace);
} else {
return null;
}
}

default Block getLeftBlock(Player p, Block b) {
Location l = p.getLocation();
float yaw = l.getYaw();

// Make sure yaw is in the range 0 to 360
while (yaw < 0) {
yaw += 360;
}
yaw = yaw % 360;
// The player's yaw is their rotation in the world,
// so, we can use that to get the right face of a block!
BlockFace leftFace;
// if the player is facing SE to SW
if (yaw < 45 || yaw >= 315) {
leftFace = BlockFace.WEST;
return b.getRelative(leftFace);
}
// if the player is facing SW to NW
else if (yaw < 135) {
leftFace = BlockFace.NORTH;
return b.getRelative(leftFace);
}
// if the player is facing NW to NE
else if (yaw < 225) {
leftFace = BlockFace.EAST;
return b.getRelative(leftFace);
}
// if the player is facing NE to SE
else if (yaw < 315) {
leftFace = BlockFace.SOUTH;
return b.getRelative(leftFace);
} else {
return null;
}
}


default void setExp(Player p, int exp) {
p.setExp(0);
p.setLevel(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ public void registerRecipe(AdaptRecipe r) {

@Override
public String getDisplayName() {
return displayName == null ? Adaptation.super.getDisplayName() : (C.RESET + "" + C.BOLD + getSkill().getColor().toString() + displayName);
try {
return displayName == null ? Adaptation.super.getDisplayName() : (C.RESET + "" + C.BOLD + getSkill().getColor().toString() + displayName);
} catch (Exception ignored) {
return null;
}
}

public void registerAdvancement(AdaptAdvancement a) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ public void addStats(int level, Element v) {
}


@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.LOW)
public void on(CraftItemEvent e) {
Player p = (Player) e.getWhoClicked();
if (hasAdaptation(p) && !e.getRecipe().equals(Material.AIR)) {
p.giveExp(e.getInventory().getResult().getAmount() * getLevel(p));
if (e.getInventory().getResult() != null && !e.isCancelled() && hasAdaptation(p) && e.getInventory().getResult().getAmount() > 0) {
if (e.getInventory().getResult() != null && e.getCursor() != null && e.getCursor().getAmount() < 64) {
if (p.getInventory().addItem(e.getCurrentItem()).isEmpty()) {
p.getInventory().removeItem(e.getCurrentItem());
p.giveExp(e.getInventory().getResult().getAmount() * getLevel(p));
}
}
}
}

Expand Down
125 changes: 125 additions & 0 deletions src/main/java/com/volmit/adapt/content/adaptation/rift/RiftDoor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*------------------------------------------------------------------------------
- Adapt is a Skill/Integration plugin for Minecraft Bukkit Servers
- Copyright (c) 2022 Arcane Arts (Volmit Software)
-
- 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
- (at your option) 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 com.volmit.adapt.content.adaptation.rift;

import com.volmit.adapt.Adapt;
import com.volmit.adapt.api.adaptation.SimpleAdaptation;
import com.volmit.adapt.util.C;
import com.volmit.adapt.util.Element;
import com.volmit.adapt.util.J;
import lombok.NoArgsConstructor;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.util.Vector;

import java.util.List;


public class RiftDoor extends SimpleAdaptation<RiftDoor.Config> {
public RiftDoor() {
super("rift-door");
registerConfiguration(Config.class);
setDescription(Adapt.dLocalize("Rift", "RiftResistance", "Description"));
setDisplayName(Adapt.dLocalize("Rift", "RiftResistance", "Name"));
setIcon(Material.IRON_DOOR);
setBaseCost(getConfig().baseCost);
setCostFactor(getConfig().costFactor);
setMaxLevel(getConfig().maxLevel);
setInitialCost(getConfig().initialCost);
setInterval(2218);
}


@Override
public void addStats(int level, Element v) {
v.addLore(C.ITALIC + Adapt.dLocalize("Rift", "RiftResistance", "Lore1"));
v.addLore(C.UNDERLINE + Adapt.dLocalize("Rift", "RiftResistance", "Lore2"));
}

@EventHandler(priority = EventPriority.HIGHEST)
public void on(BlockDamageEvent e) {
if (hasAdaptation(e.getPlayer()) && !e.isCancelled()) {
Player p = e.getPlayer();
Block b = e.getBlock();
List<Block> door = List.of(
e.getBlock().getRelative(0, 1, 0), getRightBlock(p, e.getBlock().getRelative(0, 1, 0)), getLeftBlock(p, e.getBlock().getRelative(0, 1, 0)),
e.getBlock(), getRightBlock(p, b), getLeftBlock(p, b),
e.getBlock().getRelative(0, -1, 0), getRightBlock(p, e.getBlock().getRelative(0, -1, 0)), getLeftBlock(p, e.getBlock().getRelative(0, -1, 0))
);
for (Block block : door) {
doBlockThings(block);
}
}
}

void doBlockThings(Block b) {
World w = b.getWorld();
Material mat = b.getType();
if (b.getType().equals(Material.AIR)) {
return;
}
Entity entity = w.spawnFallingBlock(b.getLocation().add(0.5, 0, 0.5), mat.createBlockData());
b.setType(Material.AIR);
J.a(() -> {
J.s(() -> {
entity.setGravity(false);
entity.setVelocity(new Vector(0, 0, 0));
vfxSingleCubeOutline(b, Particle.REVERSE_PORTAL);
entity.getWorld().playSound(entity.getLocation(), Sound.BLOCK_ENDER_CHEST_OPEN, 1f, 1f);
});
try {
Thread.sleep(3000);
} catch (Exception ignored) {
}
J.s(() -> {
entity.getWorld().playSound(entity.getLocation(), Sound.BLOCK_ENDER_CHEST_CLOSE, 1f, 1f);
entity.getLocation().getWorld().setBlockData(entity.getLocation(), mat.createBlockData());
entity.remove();
});
});
}


@Override
public void onTick() {

}

@Override
public boolean isEnabled() {
return getConfig().enabled;
}

@NoArgsConstructor
protected static class Config {
boolean enabled = false;
int baseCost = 3;
double costFactor = 1;
int maxLevel = 1;
int initialCost = 5;
}
}
87 changes: 48 additions & 39 deletions src/main/java/com/volmit/adapt/content/skill/SkillCrafting.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,46 +63,55 @@ public SkillCrafting() {

@EventHandler(priority = EventPriority.HIGHEST)
public void on(CraftItemEvent e) {
ItemStack test = e.getRecipe().getResult().clone();
int recipeAmount = e.getInventory().getResult().getAmount();
switch (e.getClick()) {
case NUMBER_KEY:
if (e.getWhoClicked().getInventory().getItem(e.getHotbarButton()) != null) {
recipeAmount = 0;
Player p = (Player) e.getWhoClicked();
if (e.getInventory().getResult() != null && !e.isCancelled() && e.getInventory().getResult().getAmount() > 0) {
if (e.getInventory().getResult() != null && e.getCursor() != null && e.getCursor().getAmount() < 64) {
if (p.getInventory().addItem(e.getCurrentItem()).isEmpty()) {
p.getInventory().removeItem(e.getCurrentItem());

ItemStack test = e.getRecipe().getResult().clone();
int recipeAmount = e.getInventory().getResult().getAmount();
switch (e.getClick()) {
case NUMBER_KEY:
if (e.getWhoClicked().getInventory().getItem(e.getHotbarButton()) != null) {
recipeAmount = 0;
}
break;

case DROP:
case CONTROL_DROP:
ItemStack cursor = e.getCursor();
if (!(cursor == null || cursor.getType().isAir())) {
recipeAmount = 0;
}
break;

case SHIFT_RIGHT:
case SHIFT_LEFT:
if (recipeAmount == 0) {
break;
}

int maxCraftable = getMaxCraftAmount(e.getInventory());
int capacity = fits(test, e.getView().getBottomInventory());
if (capacity < maxCraftable) {
maxCraftable = ((capacity + recipeAmount - 1) / recipeAmount) * recipeAmount;
}

recipeAmount = maxCraftable;
break;
default:
}

if (recipeAmount > 0 && !e.isCancelled()) {

double v = recipeAmount * getValue(test) * getConfig().craftingValueXPMultiplier;
getPlayer((Player) e.getWhoClicked()).getData().addStat("crafted.items", recipeAmount);
getPlayer((Player) e.getWhoClicked()).getData().addStat("crafted.value", v);
xp((Player) e.getWhoClicked(), v + getConfig().baseCraftingXP);
}
}
break;

case DROP:
case CONTROL_DROP:
ItemStack cursor = e.getCursor();
if (!(cursor == null || cursor.getType().isAir())) {
recipeAmount = 0;
}
break;

case SHIFT_RIGHT:
case SHIFT_LEFT:
if (recipeAmount == 0) {
break;
}

int maxCraftable = getMaxCraftAmount(e.getInventory());
int capacity = fits(test, e.getView().getBottomInventory());
if (capacity < maxCraftable) {
maxCraftable = ((capacity + recipeAmount - 1) / recipeAmount) * recipeAmount;
}

recipeAmount = maxCraftable;
break;
default:
}

if (recipeAmount > 0 && !e.isCancelled()) {

double v = recipeAmount * getValue(test) * getConfig().craftingValueXPMultiplier;
getPlayer((Player) e.getWhoClicked()).getData().addStat("crafted.items", recipeAmount);
getPlayer((Player) e.getWhoClicked()).getData().addStat("crafted.value", v);
xp((Player) e.getWhoClicked(), v + getConfig().baseCraftingXP);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public SkillRift() {
registerAdaptation(new RiftEnderchest());
registerAdaptation(new RiftGate());
registerAdaptation(new RiftBlink());
registerAdaptation(new RiftDoor());
}

@EventHandler(priority = EventPriority.HIGHEST)
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,16 @@
"Description": "Erhalte mehr Erfahrung und mehr Fische beim Fischen!",
"Lore1": "Für jedes Level gibt es eine Chance mehr Erfahrung und Fische zu erhalten"
},
"TurtlesMiningSpeed": {
"Name": "Schildkröten Miner",
"Description": "Erhalte Eile beim Bergbau unter Wasser!",
"Lore1": "Eile 3 wird während des Abbaus unter Wasser angewendet (stapelt sich mit Wasseraffinität), nachdem der Effekt der Wasseratmung nachlässt!"
},
"TurtlesVision": {
"Name": "Vision der Schildkröte",
"Description": "Erhalte Nachsicht, wenn du unter Wasser bist",
"Lore1": "Erhalte Nachtsicht unter Wasser, wenn der Effekt der Wasseratmung nachlässt!"
},
"DolphinGrace": {
"Name": "Delphins Anmut",
"Description": "Schwimm wie ein Delphin, ohne einen Delphine!",
Expand Down
Loading

0 comments on commit 93b9e9e

Please sign in to comment.