forked from JustS-js/CatTeleportMod-Fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92e2c28
commit 55c80de
Showing
6 changed files
with
71 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,31 @@ | ||
package net.just_s.ctpmod.config; | ||
|
||
import com.google.gson.Gson; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.experimental.SuperBuilder; | ||
import me.shedaniel.autoconfig.annotation.ConfigEntry; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import me.shedaniel.clothconfig2.api.ModifierKeyCode; | ||
import net.minecraft.client.option.KeyBinding; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@SuperBuilder | ||
public class Point { | ||
@ConfigEntry.Gui.Tooltip | ||
private String name; | ||
@ConfigEntry.Gui.Tooltip | ||
private int startPeriod; | ||
@ConfigEntry.Gui.Tooltip | ||
private int endPeriod; | ||
|
||
public Point() {} | ||
|
||
public Point(String name, int startPeriod, int endPeriod) { | ||
this.name = name; | ||
this.startPeriod = startPeriod; | ||
this.endPeriod = endPeriod; | ||
} | ||
|
||
public String getName() {return this.name;} | ||
|
||
public void setName(String newName) {this.name = newName;} | ||
|
||
public String toJson() { | ||
Map<String, String> point = new HashMap<>(); | ||
point.put("name", this.name); | ||
point.put("startPeriod", "" + this.startPeriod); | ||
point.put("endPeriod", "" + this.endPeriod); | ||
Gson gson = new Gson(); | ||
return gson.toJson(point); | ||
} | ||
@ConfigEntry.Gui.Tooltip | ||
private ModifierKeyCode keybind; | ||
|
||
@Override | ||
public String toString() { | ||
return "Point §f" + name + " §2with period: §f" + startPeriod + "-" + endPeriod + "§2."; | ||
} | ||
|
||
public void setStartPeriod(int value) { | ||
this.startPeriod = value; | ||
} | ||
|
||
public void setEndPeriod(int value) { | ||
this.endPeriod = value; | ||
} | ||
|
||
public int getStartPeriod() { | ||
return this.startPeriod; | ||
} | ||
|
||
public int getEndPeriod() { | ||
return this.endPeriod; | ||
return "Point §f" + name + " §2with period: §f" + startPeriod + "-" + endPeriod + "§2 and keybind:§f" + keybind.toString() + "§2."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package net.just_s.ctpmod.util; | ||
|
||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
import net.just_s.ctpmod.CTPMod; | ||
import net.just_s.ctpmod.config.Point; | ||
|
||
public class KeybindRegistry { | ||
public static void registerKeyBinds() { | ||
ClientTickEvents.END_CLIENT_TICK.register(client -> { | ||
for(Point point : CTPMod.CONFIG.points) { | ||
if(point.getKeybind().matchesCurrentKey()) CTPMod.startReconnect(point); | ||
} | ||
}); | ||
} | ||
} |