Skip to content

Commit

Permalink
3.4.0
Browse files Browse the repository at this point in the history
마인크래프트 v1_20_R3(1.20.4) 지원
생존 본능 버프

Signed-off-by: Daybreak365 <[email protected]>
  • Loading branch information
Daybreak365 committed Dec 31, 2023
1 parent 8f0764d commit a9fbb9b
Show file tree
Hide file tree
Showing 42 changed files with 987 additions and 886 deletions.
6 changes: 6 additions & 0 deletions modules/Jar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>kr.daybreak</groupId>
<artifactId>v1_20_R3</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down
6 changes: 3 additions & 3 deletions modules/Plugin/src/daybreak/abilitywar/AbilityWar.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ public void onEnable() {
Class.forName(FastMath.class.getName());
Class.forName(SpecialThanks.class.getName());
Class.forName(AbilityList.class.getName());
} catch (NoClassDefFoundError ignored) {
ignored.printStackTrace();
ignored.getCause().printStackTrace();
} catch (NoClassDefFoundError e) {
e.printStackTrace();
e.getCause().printStackTrace();
} catch (Exception ignored) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,27 @@
import daybreak.abilitywar.utils.base.concurrent.TimeUnit;
import daybreak.abilitywar.utils.base.math.LocationUtil;
import daybreak.abilitywar.utils.base.minecraft.entity.health.event.PlayerSetHealthEvent;
import daybreak.abilitywar.utils.base.minecraft.nms.IWorldBorder;
import daybreak.abilitywar.utils.base.minecraft.nms.NMS;
import daybreak.abilitywar.utils.library.PotionEffects;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.util.Vector;

import java.util.function.Predicate;

@AbilityManifest(name = "생존 본능", rank = Rank.B, species = Species.HUMAN, explain = {
"게임 중 단 한 번 §c치명적인 공격§f을 받았을 때 체력을 §c반 칸 §f남기고 살아납니다.",
"능력이 발동되면 주변의 생명체들을 모두 밀쳐내고 §b신속 II §f효과를 5초간 받으며,",
"4초간 §d무적§f/§d공격 불능 §f상태가 됩니다."
"게임 중 단 한 번 §c치명적인 공격§f을 받았을 때 체력을 §c세 칸 §f남기고 살아납니다.",
"능력이 발동되면 주변의 생명체들을 모두 밀쳐내고 §b신속 III §f효과를 5초간 받으며,",
"4초간 §d무적§f/§d공격 불능 §f상태가 됩니다.",
"다른 플레이어를 처치할 경우, 능력이 초기화되어 한 번 더 사용할 수 있습니다."
}, summarize = {
"§c§n단 한 번§f 치명적인 피해를 체력 반 칸으로 줄이고 §3무적§f, §7공격 불가§f, §b신속§f 효과를 받습니다."
})
Expand Down Expand Up @@ -62,14 +66,14 @@ public SurvivalInstinct(Participant participant) {

private void ability() {
invincibility.start();
getPlayer().setHealth(1);
getPlayer().setHealth(Math.min(6, getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
NMS.broadcastEntityEffect(getPlayer(), (byte) 2);
NMS.broadcastEntityEffect(getPlayer(), (byte) 35);
final Vector playerLocation = getPlayer().getLocation().toVector();
for (LivingEntity entity : LocationUtil.getNearbyEntities(LivingEntity.class, getPlayer().getLocation(), 6, 6, predicate)) {
entity.setVelocity(entity.getLocation().toVector().subtract(playerLocation).normalize().multiply(2).setY(0));
}
PotionEffects.SPEED.addPotionEffect(getPlayer(), 100, 1, true);
PotionEffects.SPEED.addPotionEffect(getPlayer(), 100, 2, true);
}

@SubscribeEvent(onlyRelevant = true, priority = 6, ignoreCancelled = true, childs = {EntityDamageByBlockEvent.class})
Expand Down Expand Up @@ -102,14 +106,25 @@ private void onPlayerSetHealth(PlayerSetHealthEvent e) {
}
}

@SubscribeEvent
private void onPlayerDeath(PlayerDeathEvent e) {
if (getPlayer().equals(e.getEntity().getKiller()) && invincibility.started) {
getPlayer().sendMessage("§d능력을 다시 사용할 수 있습니다!");
invincibility.started = false;
}
}

private class Invincibility extends AbilityTimer {

private final IWorldBorder worldBorder;
private final ActionbarChannel actionbarChannel = newActionbarChannel();
private boolean started = false;

private Invincibility(final int ticks) {
super(ticks);
setPeriod(TimeUnit.TICKS, 1);
this.worldBorder = NMS.createWorldBorder(getPlayer().getWorld().getWorldBorder());
worldBorder.setWarningDistance(Integer.MAX_VALUE);
}

@Override
Expand All @@ -121,6 +136,7 @@ public boolean start() {
@Override
protected void onStart() {
started = true;
NMS.setWorldBorder(getPlayer(), worldBorder);
}

@Override
Expand All @@ -135,13 +151,8 @@ protected void onEnd() {

@Override
protected void onSilentEnd() {
actionbarChannel.unregister();
getRestriction().new Condition() {
@Override
public boolean condition() {
return true;
}
}.register();
actionbarChannel.update(null);
NMS.resetWorldBorder(getPlayer());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
import daybreak.abilitywar.utils.base.minecraft.version.NMSVersion;
import kotlin.annotation.MustBeDocumented;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.*;

public class Support {

Expand All @@ -20,7 +16,7 @@ private Support() {}
public @interface Version {
NMSVersion min();

NMSVersion max() default NMSVersion.v1_19_R2;
NMSVersion max() default NMSVersion.v1_20_R3;
}

@Retention(RetentionPolicy.RUNTIME)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package daybreak.abilitywar.utils.base.minecraft;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

Expand All @@ -8,6 +10,7 @@
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.Duration;

/**
* Mojang API Wrapper
Expand All @@ -31,4 +34,25 @@ public static String getNickname(String uuid) throws IOException {
return object.get("name").getAsString();
}

private static final Cache<String, SkinInfo> skins = CacheBuilder.newBuilder()
.expireAfterAccess(Duration.ofMinutes(30))
.build();

public static SkinInfo getSkin(String name) throws IOException {
final SkinInfo cachedSkin = skins.getIfPresent(name);
if (cachedSkin != null) return cachedSkin;
final URL url0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
final InputStreamReader reader_0 = new InputStreamReader(url0.openStream());
final String uuid = JsonParser.parseReader(reader_0).getAsJsonObject().get("id").getAsString();

final URL url1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false");
final InputStreamReader reader_1 = new InputStreamReader(url1.openStream());
final JsonObject textureProperty = JsonParser.parseReader(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
final String texture = textureProperty.get("value").getAsString();
final String signature = textureProperty.get("signature").getAsString();
final SkinInfo info = new SkinInfo(name, texture, signature);
skins.put(name, info);
return info;
}

}
Loading

0 comments on commit a9fbb9b

Please sign in to comment.