Skip to content

Commit

Permalink
feat: first pre version
Browse files Browse the repository at this point in the history
  • Loading branch information
m1919810 committed Aug 25, 2024
1 parent 2a5f835 commit 1a5accc
Show file tree
Hide file tree
Showing 79 changed files with 3,389 additions and 765 deletions.
28 changes: 27 additions & 1 deletion .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<id>paper-repo</id>
<url>https://repo.destroystokyo.com/repository/maven-public/</url>
</repository>

<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/me/matl114/logitech/Items/CustomHead.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ public enum CustomHead {
MATL114("58d9d8a7927fb859a313fb0068f1d368c9dee7d0adacbbd35ffa4d998ff88deb"),
LOGIC_REACTOR("87e04b5b252a6f4e6473ea952450a9d8d8db4cd657ffd9b419c25c6c80408f3e"),
BUG_CRATFER("f2fdb5a1477cb38109030fc9e41691668e4fe05c86aad46c6ad01f4ce4dabd52"),
MOTOR("8cbca012f67e54de9aee72ff424e056c2ae58de5eacc949ab2bcd9683cec")
MOTOR("8cbca012f67e54de9aee72ff424e056c2ae58de5eacc949ab2bcd9683cec"),
CORE("d78f2b7e5e75639ea7fb796c35d364c4df28b4243e66b76277aadcd6261337"),
VSPACE("93e2f779147bc025487b27a37b7fc516d7489c589df97016eb8dc0f54d3bf29e"),
BUSHIGEMEN("8064777a09c00a4a92eee74aba7c672bfea7f0384b256894ea261d5a915af8ee"),
SUPPORT("6bf5374986e6c8e302ee3658d8553038b6d93abd323f4aae950624ccedaf905"),
REVERSE("246f958ed3dbbb0cda4739b9b0959be8d03f6121936934c6600d3f74538511da")
;
private ItemStack item;
public ItemStack getItem() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@
import org.bukkit.event.player.PlayerPortalEvent;

public class PortalTeleport implements Listener {
public final int[] dx=new int[]{0,1,0,-1,0};
public final int[] dz=new int[]{0,0,1,0,-1};
public final int[] dx=new int[]{0,1,0,-1,0,1,1,-1,-1};
public final int[] dz=new int[]{0,0,1,0,-1,1,-1,-1,1};
@EventHandler
//沉浸式体验传送门 abab
//FIXME 目标传送门未激活时传送有误
public void onTeleportRedirect(PlayerPortalEvent event) {
Location loco = event.getFrom();
int x = loco.getBlockX();
int y = loco.getBlockY()-1;
int z = loco.getBlockZ();
loco=new Location(loco.getWorld(),x,y,z);
Location loc;
for(int i=0;i<5;++i) {
for(int i=0;i<9;++i) {
loc=loco.clone().add(dx[i],0,dz[i]);
if(loc.getBlock().getType()!= Material.CRYING_OBSIDIAN){
continue;
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/me/matl114/logitech/MyAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import me.matl114.logitech.Depends.DependencyInfinity;
import me.matl114.logitech.Depends.DependencyNetwork;
import me.matl114.logitech.Listeners.ListenerManager;
import me.matl114.logitech.Schedule.PersistentEffects.CustomEffects;
import me.matl114.logitech.Schedule.PersistentEffects.RadiationRegion;
import me.matl114.logitech.Schedule.Schedules;
import me.matl114.logitech.SlimefunItem.AddDepends;
import me.matl114.logitech.SlimefunItem.AddGroups;
Expand Down Expand Up @@ -81,6 +83,10 @@ public void onEnable() {
MultiBlockService.setup();
//注册多方块类型
MultiBlockTypes.setup();
//加载自定义效果机制
CustomEffects.setup();
//加载辐射机制
RadiationRegion.setup();
//加载配方工具
CraftUtils.setup();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package me.matl114.logitech.Schedule.PersistentEffects;

import me.matl114.logitech.Utils.AddUtils;
import org.bukkit.damage.DamageSource;
import org.bukkit.damage.DamageType;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public class CustomEffects {
public static void setup(){

}
public static void registerEffect(){

}
Expand All @@ -25,15 +30,43 @@ public void aquireEffect(Player p,int level) {
public void removeEffect(Player p,int level) {
}
public void tickEffect(Player p,int level) {
p.addPotionEffect(new PotionEffect( PotionEffectType.DARKNESS,140,1,false ),true);
p.addPotionEffect(new PotionEffect( PotionEffectType.WITHER,140,1,false ),true);
p.setFireTicks(200);
p.damage(level==1?1:50);
p.addPotionEffect(new PotionEffect( PotionEffectType.DARKNESS,140,3*level,false ),true);
p.addPotionEffect(new PotionEffect( PotionEffectType.WITHER,140,3*level,false ),true);
if(level==1){
p.damage(5);
}else {
AddUtils.damageGeneric(p,50);

}
}
public void aquireEffect(Player p,int level) {
}
public void onDeathEvent(PlayerDeathEvent e) {
e.setDeathMessage(AddUtils.resolveColor( "%s &6在超新星的烈焰中化为灰烬".formatted(e.getEntity().getName())));
}
};
public static AbstractEffect RADIATION= new AbstractEffect("RADIATION") {
public void removeEffect(Player p,int level) {

}
public void tickEffect(Player p,int level) {
p.addPotionEffect(new PotionEffect( PotionEffectType.DARKNESS,140,10*level,false ),true);
p.addPotionEffect(new PotionEffect( PotionEffectType.WITHER,140,10*level,false ),true);
p.addPotionEffect(new PotionEffect( PotionEffectType.SLOW,140,10*level,false ),true);
p.addPotionEffect(new PotionEffect( PotionEffectType.HUNGER,140,10*level,false ),true);
p.addPotionEffect(new PotionEffect( PotionEffectType.POISON,140,10*level,false ),true);
if(level==1){
p.damage(5);
}else {
AddUtils.damageGeneric(p,500);

}
}
public void aquireEffect(Player p,int level) {

}
public void onDeathEvent(PlayerDeathEvent e) {
e.setDeathMessage(AddUtils.resolveColor( "%s &6的身体被核辐射穿成了筛子".formatted(e.getEntity().getName())));
}
};
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.matl114.logitech.Schedule.PersistentEffects;

import me.matl114.logitech.Schedule.ScheduleEffects;
import me.matl114.logitech.Schedule.Schedules;
import org.bukkit.entity.Player;

import java.util.function.Function;
Expand Down Expand Up @@ -53,8 +54,7 @@ public int getLeftTime(){
}
public static void grantEffect(AbstractEffect type, Player p, int level, int time, Function<Player,Boolean> predicate){
PlayerEffects eff = new PlayerEffects(type,time,level);
if( ScheduleEffects.addEffect(p,eff,predicate))
eff.start(p);
ScheduleEffects.addEffect(p,eff,predicate);
}
public static void grantEffect(AbstractEffect type, Player p, int level, int time){
PlayerEffects eff = new PlayerEffects(type,time,level);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package me.matl114.logitech.Schedule.PersistentEffects;

import me.matl114.logitech.Schedule.ScheduleSave;
import me.matl114.logitech.Schedule.Schedules;
import me.matl114.logitech.Utils.AddUtils;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

import java.util.Collection;
import java.util.LinkedHashMap;

public class RadiationRegion {
public static void setup(){

}
protected static final byte[] lock = new byte[0];
protected static final LinkedHashMap<Location,BukkitRunnable> RADIATION_THREAD=new LinkedHashMap<>();
static{
ScheduleSave.addFinalTask(()->{
for(BukkitRunnable it:RADIATION_THREAD.values()){
it.cancel();
}
});
}
public static boolean removeRadiation(Location loc){
BukkitRunnable t;
synchronized(lock){
t=RADIATION_THREAD.remove(loc);
}
if(t!=null){
t.cancel();
return true;
}else {
return false;
}
}
public static void addRadiation(Location loc, int range,int period,int speed,int level){
removeRadiation(loc);
BukkitRunnable task=new BukkitRunnable(){
public int radiation=period;
Location center=loc.clone();
public void run(){
if(radiation>0){
--radiation;
runRadiation(center,range,level);
}else {
cancel();
}
}
};
synchronized (lock){
RADIATION_THREAD.put(loc,task);
}
Schedules.launchSchedules(task,speed,true,speed);
}

/**
* must run in sync thread
* @param loc
* @param range
* @param level
*/
public static void runRadiation(Location loc,int range,int level){
Collection<Entity> entities=loc.getWorld().getNearbyEntities(loc,
range,range,range
,(entity -> entity instanceof Player));
for(Entity entity:entities){
if(entity instanceof Player player){
AddUtils.sendMessage(player,"&e警告!您已进入危险的辐射区!");
PlayerEffects.grantEffect(CustomEffects.RADIATION,
player,level,60,(player1 -> {return loc.distance(player1.getLocation())<1.4*range;}));
}
}
}
}
Loading

0 comments on commit 1a5accc

Please sign in to comment.