Skip to content

Commit

Permalink
Merge pull request #195 from VolmitSoftware/Development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NextdoorPsycho authored Sep 18, 2022
2 parents 40caaf6 + d04d7ea commit 7550f6c
Show file tree
Hide file tree
Showing 37 changed files with 380 additions and 33 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.3.1-1.19.2' // Needs to be version specific
version '1.3.2-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
2 changes: 1 addition & 1 deletion src/main/java/com/volmit/adapt/Adapt.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private void startupPrint() {
Random r = new Random();
int game = r.nextInt(100);

if (game < 85){ // 85%
if (game < 90){ // 90%
Adapt.info(
"\n" +
C.GRAY + " █████" + C.DARK_RED + "╗ " + C.GRAY + "██████" + C.DARK_RED + "╗ " + C.GRAY + "█████" + C.DARK_RED + "╗ " + C.GRAY + "██████" + C.DARK_RED + "╗ " + C.GRAY + "████████" + C.DARK_RED + "╗\n" +
Expand Down
19 changes: 15 additions & 4 deletions src/main/java/com/volmit/adapt/api/adaptation/Adaptation.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.volmit.adapt.api.tick.Ticked;
import com.volmit.adapt.api.world.AdaptPlayer;
import com.volmit.adapt.api.world.PlayerData;
import com.volmit.adapt.content.event.AdaptAdaptationUseEvent;
import com.volmit.adapt.util.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
Expand All @@ -35,11 +36,10 @@
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockCanBuildEvent;
import org.bukkit.inventory.Recipe;

import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

public interface Adaptation<T> extends Ticked, Component {
int getMaxLevel();
Expand Down Expand Up @@ -76,6 +76,17 @@ default boolean setStorage(Player p, String key, Object value) {
return false;
}

default boolean canUse(AdaptPlayer player) {
AdaptAdaptationUseEvent e = new AdaptAdaptationUseEvent(!Bukkit.isPrimaryThread(), player, this);
Bukkit.getServer().getPluginManager().callEvent(e);
return (!e.isCancelled());
}

default boolean canUse(Player player) {
return canUse(getPlayer(player));
}


default String getStorageString(Player p, String key, String defaultValue) {
return getStorage(p, key, defaultValue);
}
Expand Down Expand Up @@ -301,8 +312,8 @@ default void openGui(Player player) {
.setProgress(1D)
.addLore(Form.wrapWordsPrefixed(getDescription(), "" + C.GRAY, 40))
.addLore(mylevel >= lvl ? ("") : ("" + C.WHITE + c + C.GRAY + " " + Adapt.dLocalize("snippets", "adaptmenu", "knowledgecost")))
.addLore(mylevel >= lvl ? (C.GREEN + Adapt.dLocalize("snippets", "adaptmenu", "alreadylearned") + " " + C.GRAY + Adapt.dLocalize("snippets", "adaptmenu", "unlearnrefund") + " " + C.GREEN + rc + " " + Adapt.dLocalize("snippets", "adaptmenu", "knowledgecost")) : (k >= c ? (C.BLUE + Adapt.dLocalize("snippets", "adaptmenu", "clicklearn") + " " + getDisplayName(i)) : (k == 0 ? (C.RED + Adapt.dLocalize("snippets", "adaptmenu", "noknowledge")) : (C.RED + "(" + Adapt.dLocalize("snippets", "adaptmenu", "youonlyhave") + " " + C.WHITE + k + C.RED + " " + Adapt.dLocalize("snippets", "adaptmenu", "knowledgecost") + ")"))))
.addLore(mylevel < lvl && getPlayer(player).getData().hasPowerAvailable(pc) ? C.GREEN + "" + lvl + " " + Adapt.dLocalize("snippets", "adaptmenu", "power") : mylevel >= lvl ? C.GREEN + "" + lvl + " " + Adapt.dLocalize("snippets", "adaptmenu", "power") : C.RED + Adapt.dLocalize("snippets", "adaptmenu", "notenoughpower") + " \n" + C.RED + Adapt.dLocalize("snippets", "adaptmenu", "howtolevelup"))
.addLore(mylevel >= lvl ? (C.GREEN + Adapt.dLocalize("snippets", "adaptmenu", "alreadylearned") + " " + C.GRAY + Adapt.dLocalize("snippets", "adaptmenu", "unlearnrefund") + "" + C.GREEN + rc + " " + Adapt.dLocalize("snippets", "adaptmenu", "knowledgecost")) : (k >= c ? (C.BLUE + Adapt.dLocalize("snippets", "adaptmenu", "clicklearn") + " " + getDisplayName(i)) : (k == 0 ? (C.RED + Adapt.dLocalize("snippets", "adaptmenu", "noknowledge")) : (C.RED + "(" + Adapt.dLocalize("snippets", "adaptmenu", "youonlyhave") + " " + C.WHITE + k + C.RED + " " + Adapt.dLocalize("snippets", "adaptmenu", "knowledgecost") + ")"))))
.addLore(mylevel < lvl && getPlayer(player).getData().hasPowerAvailable(pc) ? C.GREEN + "" + lvl + " " + Adapt.dLocalize("snippets", "adaptmenu", "power") : mylevel >= lvl ? C.GREEN + "" + lvl + " " + Adapt.dLocalize("snippets", "adaptmenu", "power") : C.RED + Adapt.dLocalize("snippets", "adaptmenu", "notenoughpower") + "\n" + C.RED + Adapt.dLocalize("snippets", "adaptmenu", "howtolevelup"))
.onLeftClick((e) -> {
if (mylevel >= lvl) {
getPlayer(player).getData().getSkillLine(getSkill().getName()).giveKnowledge(rc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class CommandBoost extends MortarCommand {
@Command
private CommandBoostPlayer player = new CommandBoostPlayer();

private static final List<String> permission = List.of("adapt.boostplayer");
private static final List<String> permission = List.of("adapt.boost");

public CommandBoost() {
super("boost", "b");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerQuitEvent;

import java.util.HashMap;
import java.util.Map;

public class AgilityArmorUp extends SimpleAdaptation<AgilityArmorUp.Config> {
private final Map<Player, Integer> ticksRunning = new HashMap<>();
private final Map<Player, Integer> ticksRunning;


public AgilityArmorUp() {
super("agility-armor-up");
Expand All @@ -50,6 +52,7 @@ public AgilityArmorUp() {
setCostFactor(getConfig().costFactor);
setInitialCost(getConfig().initialCost);
setInterval(350);
ticksRunning = new HashMap<>();
}

@Override
Expand All @@ -72,6 +75,7 @@ private double getWindupArmor(double factor) {
return getConfig().windupArmorBase + (factor * getConfig().windupArmorLevelMultiplier);
}


@Override
public void onTick() {
for (Player i : Bukkit.getOnlinePlayers()) {
Expand All @@ -87,6 +91,8 @@ public void onTick() {
}

if (i.isSprinting() && hasAdaptation(i)) {


ticksRunning.compute(i, (k, v) -> {
if (v == null) {
return 1;
Expand Down Expand Up @@ -114,7 +120,7 @@ public void onTick() {
i.getWorld().spawnParticle(Particle.WAX_ON, i.getLocation(), 1, 0, 0, 0, 0);
}
}
i.getAttribute(Attribute.GENERIC_ARMOR).addModifier(new AttributeModifier("adapt-armor-up", armorInc*10, AttributeModifier.Operation.ADD_NUMBER));
i.getAttribute(Attribute.GENERIC_ARMOR).addModifier(new AttributeModifier("adapt-armor-up", armorInc * 10, AttributeModifier.Operation.ADD_NUMBER));

} else {
ticksRunning.remove(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@


public class AgilitySuperJump extends SimpleAdaptation<AgilitySuperJump.Config> {
private final Map<Player, Long> lastJump = new HashMap<>();
private final Map<Player, Long> lastJump;

public AgilitySuperJump() {
super("agility-super-jump");
Expand All @@ -56,6 +56,7 @@ public AgilitySuperJump() {
setMaxLevel(getConfig().maxLevel);
setInitialCost(getConfig().initialCost);
setInterval(9999);
lastJump = new HashMap<>();
}

private double getJumpHeight(int level) {
Expand Down Expand Up @@ -101,7 +102,7 @@ public void on(PlayerMoveEvent e) {
return;
}

if (p.isSneaking() && hasAdaptation(p)) {
if (p.isSneaking() && hasAdaptation(p) && canUse(getPlayer(p))) {
Vector velocity = p.getVelocity();

if (velocity.getY() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import java.util.Map;

public class AgilityWallJump extends SimpleAdaptation<AgilityWallJump.Config> {
private final Map<Player, Double> airjumps = new HashMap<>();
private final Map<Player, Double> airjumps;

public AgilityWallJump() {
super("agility-wall-jump");
Expand All @@ -53,6 +53,7 @@ public AgilityWallJump() {
setMaxLevel(getConfig().maxLevel);
setInitialCost(getConfig().initialCost);
setInterval(50);
airjumps = new HashMap<>();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.Map;

public class AgilityWindUp extends SimpleAdaptation<AgilityWindUp.Config> {
private final Map<Player, Integer> ticksRunning = new HashMap<>();
private final Map<Player, Integer> ticksRunning;

public AgilityWindUp() {
super("agility-wind-up");
Expand All @@ -50,6 +50,7 @@ public AgilityWindUp() {
setCostFactor(getConfig().costFactor);
setInitialCost(getConfig().initialCost);
setInterval(120);
ticksRunning = new HashMap<>();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public DiscoveryArmor() {
@Override
public void addStats(int level, Element v) {
v.addLore(C.GREEN + "+ " + Adapt.dLocalize("discovery", "armor", "lore1") + C.GRAY + ", " + Adapt.dLocalize("discovery", "armor", "lore2"));
v.addLore(Adapt.dLocalize("discovery", "armor", "lore3") + C.BLUE + level * 0.25);
v.addLore(C.YELLOW + "~ " + Adapt.dLocalize("discovery", "armor", "lore3") + C.BLUE + " +"+ level * 0.25);
}

public double getArmorPoints(Material m) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public DiscoveryVillagerAtt() {
@Override
public void addStats(int level, Element v) {
v.addLore(C.GREEN + "+ " + C.GRAY + Adapt.dLocalize("discovery", "villager", "lore1"));
v.addLore(C.GREEN + "+ " + Form.pc(getEffectiveness(getLevelPercent(level)), 0) + C.GRAY + Adapt.dLocalize("discovery", "villager", "lore2"));
v.addLore(C.GREEN + "+ " + Form.pc(getEffectiveness(getLevelPercent(level)), 0) + C.GRAY + " " + Adapt.dLocalize("discovery", "villager", "lore2"));
v.addLore(C.GREEN + "+ " + getXpTaken(level) + " " + C.GRAY + Adapt.dLocalize("discovery", "villager", "lore3"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public void on(BlockDropItemEvent e) {
if (p.getGameMode() != GameMode.SURVIVAL) {
return;
}
p.sendMessage("Dropped");
if (ItemListings.toolPickaxes.contains(p.getInventory().getItemInMainHand().getType())) {
List<Item> items = e.getItems().copy();
e.getItems().clear();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*------------------------------------------------------------------------------
- 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.event;

import com.volmit.adapt.api.adaptation.Adaptation;
import com.volmit.adapt.api.skill.Skill;
import com.volmit.adapt.api.world.AdaptPlayer;
import com.volmit.adapt.api.world.PlayerSkillLine;

public class AdaptAdaptationEvent extends AdaptPlayerEvent {
private final Skill<?> skill;
private final PlayerSkillLine playerSkill;
private final Adaptation<?> adaptation;

public AdaptAdaptationEvent(boolean async, AdaptPlayer player, Adaptation<?> adaptation) {
super(async, player);
this.adaptation = adaptation;
this.playerSkill = player.getSkillLine(adaptation.getSkill().getId());
this.skill = adaptation.getSkill();
}

public Skill<?> getSkill() {
return skill;
}

public Adaptation<?> getAdaptation() {
return adaptation;
}

public PlayerSkillLine getPlayerSkill() {
return playerSkill;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*------------------------------------------------------------------------------
- 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.event;

import com.volmit.adapt.api.adaptation.Adaptation;
import com.volmit.adapt.api.world.AdaptPlayer;

public class AdaptAdaptationUseEvent extends AdaptAdaptationEvent {
public AdaptAdaptationUseEvent(boolean async, AdaptPlayer player, Adaptation<?> adaptation) {
super(async, player, adaptation);
}
}
57 changes: 57 additions & 0 deletions src/main/java/com/volmit/adapt/content/event/AdaptEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*------------------------------------------------------------------------------
- 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.event;

import com.volmit.adapt.Adapt;
import com.volmit.adapt.api.world.AdaptServer;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class AdaptEvent extends Event implements Cancellable {
private boolean canceled;
private static final HandlerList handlers = new HandlerList();


public AdaptEvent(boolean async) {
super(async);
canceled = false;
}

public AdaptServer getServer() {
return Adapt.instance.getAdaptServer();
}

@Override
public boolean isCancelled() {
return canceled;
}

@Override
public void setCancelled(boolean b) {
canceled = b;
}

@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
}
34 changes: 34 additions & 0 deletions src/main/java/com/volmit/adapt/content/event/AdaptPlayerEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*------------------------------------------------------------------------------
- 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.event;

import com.volmit.adapt.api.world.AdaptPlayer;

public class AdaptPlayerEvent extends AdaptEvent {
private final AdaptPlayer player;

public AdaptPlayerEvent(boolean async, AdaptPlayer player) {
super(async);
this.player = player;
}

public AdaptPlayer getPlayer() {
return player;
}
}
Loading

0 comments on commit 7550f6c

Please sign in to comment.