Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Agzam4 authored May 13, 2023
1 parent c1724fc commit 2f930c2
Show file tree
Hide file tree
Showing 10 changed files with 1,206 additions and 16 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Agzam's plugin v1.8.3",
"name": "Agzam's plugin v1.9.0",
"author": "Agzam4",
"main": "example.ExamplePlugin",
"description": "New command, events, core protection from thorium reactors and more",
Expand Down
102 changes: 90 additions & 12 deletions src/example/ExamplePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Random;

import arc.*;
import arc.files.Fi;
import arc.freetype.FreeType.Size;
import arc.func.Intc2;
import arc.graphics.Color;
Expand All @@ -21,6 +22,7 @@
import arc.struct.Seq;
import arc.util.*;
import arc.util.CommandHandler.Command;
import example.achievements.AchievementsManager;
import example.events.ServerEvent;
import example.events.ServerEventsManager;
import mindustry.*;
Expand All @@ -31,6 +33,7 @@
import mindustry.core.World;
import mindustry.ctype.Content;
import mindustry.ctype.ContentType;
import mindustry.entities.Damage;
import mindustry.entities.Effect;
import mindustry.entities.units.BuildPlan;
import mindustry.gen.Call;
Expand Down Expand Up @@ -83,16 +86,20 @@ public class ExamplePlugin extends Plugin{
MyMenu menu;

private ArrayList<String> extraStarsUIDD;
private AchievementsManager achievementsManager;

@Override
public void init() {
achievementsManager = new AchievementsManager();
// Blocks.logicProcessor
// Vars.state.rules.reactorExplosions;
// Vars.content.getBy(ContentType.unit).forEach(e -> e.spawn(97*8, 111*8));
doorsCup = Core.settings.getInt(PLUGIN_NAME + "-doors-cup", Integer.MAX_VALUE);
discordLink = Core.settings.getString(PLUGIN_NAME + "-discord-link", null);
chatFilter = Core.settings.getBool(PLUGIN_NAME + "-chat-filter", false);
extraStarsUIDD = new ArrayList<>();

doorsCoordinates = new ArrayList<>();
extraStarsUIDD = new ArrayList<>();

menu = new MyMenu();
eventsManager = new ServerEventsManager();
Expand Down Expand Up @@ -127,8 +134,12 @@ public void init() {
adminCommands.add("brush");
adminCommands.add("etrigger");
adminCommands.add("extrastar");
adminCommands.add("achievements");
adminCommands.add("whitelist");
adminCommands.add("wlsize");

Events.run(Trigger.update, () -> {
achievementsManager.update();
menu.update();
eventsManager.update();
});
Expand Down Expand Up @@ -354,6 +365,10 @@ public void init() {
} else {
tile.setFloorNet(brushFloor);
}
} else {
if(brushOverlay != null) {
tile.setFloorNet(tile.floor(), brushOverlay);
}
}
}
}
Expand Down Expand Up @@ -710,7 +725,8 @@ public void registerClientCommands(CommandHandler handler){
int typesCounter = 0;

for(int x = 0; x < world.width(); x++){
for(int y = 0; y < world.height(); y++){
for(int y = 0; y < world.height(); y++) {
if(world.tile(x, y).block() != Blocks.air) continue;
Item floor = world.tile(x, y).floor().itemDrop;
Item overlay = world.tile(x, y).overlay().itemDrop;
Liquid lfloor = world.tile(x, y).floor().liquidDrop;
Expand Down Expand Up @@ -936,7 +952,7 @@ public void registerClientCommands(CommandHandler handler){

handler.<Player>register("plugininfo", "info about pluging", (arg, player) -> {
player.sendMessage(""
+ "[green] Agzam's plugin v1.8.5\n"
+ "[green] Agzam's plugin v1.9.0\n"
+ "[gray]========================================================\n"
+ "[white] Added [royal]skip map[white] commands\n"
+ "[white] Added protection from [violet]thorium reactors[white]\n"
Expand Down Expand Up @@ -1057,9 +1073,12 @@ public void registerClientCommands(CommandHandler handler){
Team team = player.team();

int count = arg.length > 1 ? Integer.parseInt(arg[1]) : 0;
for(CoreBuild core : team.cores()){
core.items.add(item, count);

if(team.cores().size == 0) {
player.sendMessage("[red]У Вашей команды игроков нет ядер");
return;
}
team.cores().get(0).items.add(item, count);
player.sendMessage("Добавлено " + "[gold]x" + count + " [orange]" + item.name);
} else {
player.sendMessage("Предмет не найден");
Expand Down Expand Up @@ -1181,7 +1200,7 @@ public void registerClientCommands(CommandHandler handler){
for (int i = 0; i < ServerEventsManager.getServerEventsCount(); i++) {
ServerEvent event = ServerEventsManager.getServerEvent(i);
if(arg[0].equals(event.getCommandName())) {
player.sendMessage("Событие [" + event.getColor() + "]" + event.getName() + " [white] имеет значение: " + event.isRunning());
player.sendMessage("Событие [" + event.getColor() + "]" + event.getName() + "[white] имеет значение: " + event.isRunning());
return;
}
}
Expand Down Expand Up @@ -1660,7 +1679,11 @@ public void registerClientCommands(CommandHandler handler){
}
} else if(arg.length == 2) {
String blockname = arg[1];
if(arg[0].equalsIgnoreCase("block")) {
if(blockname.equals("core1")) blockname = "coreShard";
if(blockname.equals("core2")) blockname = "coreFoundation";
if(blockname.equals("core3")) blockname = "coreNucleus";

if(arg[0].equalsIgnoreCase("block") || arg[0].equalsIgnoreCase("b")) {
if(arg[1].equals("none")) {
brushBlock = null;
player.sendMessage("[gold]Блок отвязан");
Expand All @@ -1678,7 +1701,7 @@ public void registerClientCommands(CommandHandler handler){
} catch (IllegalArgumentException | IllegalAccessException e) {
player.sendMessage("[red]Доступ к блоку заблокирован");
}
} else if(arg[0].equalsIgnoreCase("floor")) {
} else if(arg[0].equalsIgnoreCase("floor") || arg[0].equalsIgnoreCase("f")) {
if(arg[1].equals("none")) {
brushFloor = null;
player.sendMessage("[gold]Поверхность отвязана");
Expand All @@ -1696,7 +1719,7 @@ public void registerClientCommands(CommandHandler handler){
} catch (IllegalArgumentException | IllegalAccessException e) {
player.sendMessage("[red]Доступ к поверхности заблокирован");
}
} else if(arg[0].equalsIgnoreCase("overlay")) {
} else if(arg[0].equalsIgnoreCase("overlay") || arg[0].equalsIgnoreCase("o")) {
if(arg[1].equals("none")) {
brushOverlay = null;
player.sendMessage("[gold]Покрытие отвязано");
Expand All @@ -1721,7 +1744,7 @@ public void registerClientCommands(CommandHandler handler){
}
});

handler.<Player>register("etrigger", "[trigger] [args...]", "Устанваливает кисточку", (args, player) -> {
handler.<Player>register("etrigger", "<trigger> [args...]", "Устанваливает кисточку", (args, player) -> {
if(player.admin()) {
eventsManager.trigger(player, args);
} else {
Expand Down Expand Up @@ -1781,6 +1804,54 @@ public void registerClientCommands(CommandHandler handler){
player.sendMessage("[red]Команда только для администраторов");
}
});


handler.<Player>register("achievements", "<load/save/path> [args...]", "Управление достижениями", (args, player) -> {
if(player.admin()) {
if(args.length > 0) {
if(args[0].equalsIgnoreCase("load")) {
if(achievementsManager.load()) {
player.sendMessage("[gold]\ue81b Загружено!");
} else {
player.sendMessage("[red]\ue81b Файл не найден!");
}
return;
}
if(args[0].equalsIgnoreCase("save")) {
achievementsManager.save();
player.sendMessage("[gold]\ue81b Сохранено!");
return;
}
if(args[0].equalsIgnoreCase("path")) {
if(args.length == 1) {
player.sendMessage("[gold]\ue81b Место хранения: [lightgray]" + achievementsManager.savePath.absolutePath());
return;
} else if(args.length == 2) {
String path = args[1] + ".json";

Fi fi = null;
if(path.startsWith("#")) {
fi = Core.files.absolute(path.substring(1));
} else {
fi = Core.files.local(path);
}
if(fi == null) {
return;
}
achievementsManager.savePath = fi;
// Fi fi = Core.files.absolute(PLUGIN_NAME)
player.sendMessage("[gold]\ue81b Установлено место хранения: [lightgray]" + achievementsManager.savePath.absolutePath());
} else {
player.sendMessage("[red]Используйте: /achievements <path> [new path] (# вначале для полного пути)");
}
}

}
} else {
player.sendMessage("[red]Команда только для администраторов");
}
});

}

String discordLink = "";
Expand Down Expand Up @@ -1850,9 +1921,12 @@ class SkipmapVoteSession {
SkipmapVoteSession[] map;
Timer.Task task;
int votes;

int votesRequiredSkipmap;

public SkipmapVoteSession(SkipmapVoteSession[] map){
this.map = map;
votesRequiredSkipmap = votesRequiredSkipmap();
this.task = Timer.schedule(() -> {
if(!checkPass()){
Call.sendMessage("[lightgray]Голосование закончилось. Недостаточно голосов, чтобы пропустить карту");
Expand All @@ -1866,12 +1940,12 @@ void vote(Player player, int d){
votes += d;
voted.addAll(player.uuid()); // FIXME: , Vars.netServer.admins.getInfo(player.uuid()).lastIP
Call.sendMessage(Strings.format("[" + colorToHex(player.color) + "]@[lightgray] проголосовал " + (d > 0 ? "[green]за" : "[red]против") + "[] пропуска карты[accent] (@/@)\n[lightgray]Напишите[orange] /smvote <y/n>[], чтобы проголосовать [green]за[]/[red]против",
player.name, votes, votesRequiredSkipmap()));
player.name, votes, votesRequiredSkipmap));
checkPass();
}

boolean checkPass(){
if(votes >= votesRequiredSkipmap()){
if(votes >= votesRequiredSkipmap) {
Call.sendMessage("[gold]Голосование закончилось. Карта успешно пропущена!");
Events.fire(new GameOverEvent(Team.derelict));
map[0] = null;
Expand All @@ -1880,6 +1954,10 @@ boolean checkPass(){
}
return false;
}

void update() {
votesRequiredSkipmap = votesRequiredSkipmap();
}
}

private String colorToHex(Color color) {
Expand Down
33 changes: 33 additions & 0 deletions src/example/Work.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package example;

import mindustry.content.Items;
import mindustry.content.UnitTypes;
import mindustry.type.UnitType;

Expand All @@ -9,4 +10,36 @@ public static boolean isPlayerUnit(UnitType unit) {
return unit == UnitTypes.alpha || unit == UnitTypes.beta || unit == UnitTypes.gamma
|| unit == UnitTypes.evoke || unit == UnitTypes.incite || unit == UnitTypes.emanate;
}


public static void localisateItemsNames() {
if(Items.copper.localizedName.equalsIgnoreCase(Items.copper.name)) {
Items.beryllium.localizedName = "бериллий";
Items.blastCompound.localizedName = "взрывчатка";
Items.carbide.localizedName = "карбид";
Items.coal.localizedName = "уголь";
Items.copper.localizedName = "медь";
Items.dormantCyst.localizedName = "оболчка";
Items.fissileMatter.localizedName = "материя";
Items.graphite.localizedName = "грфит";
Items.lead.localizedName = "свинец";
Items.metaglass.localizedName = "стекло";
Items.oxide.localizedName = "оксид";
Items.phaseFabric.localizedName = "фаза";
Items.plastanium.localizedName = "пластан";
Items.pyratite.localizedName = "пиротит";
Items.sand.localizedName = "песок";
Items.scrap.localizedName = "железо";
Items.silicon.localizedName = "кремний";
Items.sporePod.localizedName = "споры";
Items.surgeAlloy.localizedName = "кинетик";
Items.thorium.localizedName = "торий";
Items.titanium.localizedName = "титан";
Items.tungsten.localizedName = "вольфрам";
Items.fissileMatter.localizedName = "материя";
Items.dormantCyst.localizedName = "обломки";
}
}
}


Loading

0 comments on commit 2f930c2

Please sign in to comment.