Initial commit
This commit is contained in:
3
Plugins/Old/1vs1-Marc/.idea/.gitignore
generated
vendored
Normal file
3
Plugins/Old/1vs1-Marc/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
1
Plugins/Old/1vs1-Marc/.idea/.name
generated
Normal file
1
Plugins/Old/1vs1-Marc/.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
||||
MySQL.java
|
||||
8
Plugins/Old/1vs1-Marc/.idea/artifacts/1vs1.xml
generated
Normal file
8
Plugins/Old/1vs1-Marc/.idea/artifacts/1vs1.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="1vs1">
|
||||
<output-path>$USER_HOME$/Desktop/</output-path>
|
||||
<root id="archive" name="1vs1.jar">
|
||||
<element id="module-output" name="1vs1-Marc" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
7
Plugins/Old/1vs1-Marc/.idea/discord.xml
generated
Normal file
7
Plugins/Old/1vs1-Marc/.idea/discord.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
||||
11
Plugins/Old/1vs1-Marc/.idea/libraries/spigot_1_8_8.xml
generated
Normal file
11
Plugins/Old/1vs1-Marc/.idea/libraries/spigot_1_8_8.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="spigot 1.8.8">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/../Spigot Versions/spigot 1.8.8.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/../Spigot Versions/spigot 1.8.8.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
11
Plugins/Old/1vs1-Marc/.idea/misc.xml
generated
Normal file
11
Plugins/Old/1vs1-Marc/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
Plugins/Old/1vs1-Marc/.idea/modules.xml
generated
Normal file
8
Plugins/Old/1vs1-Marc/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/1vs1-Marc.iml" filepath="$PROJECT_DIR$/1vs1-Marc.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
124
Plugins/Old/1vs1-Marc/.idea/uiDesigner.xml
generated
Normal file
124
Plugins/Old/1vs1-Marc/.idea/uiDesigner.xml
generated
Normal file
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
6
Plugins/Old/1vs1-Marc/.idea/vcs.xml
generated
Normal file
6
Plugins/Old/1vs1-Marc/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
21
Plugins/Old/1vs1-Marc/1vs1-Marc.iml
Normal file
21
Plugins/Old/1vs1-Marc/1vs1-Marc.iml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="spigot 1.8.8" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11
Plugins/Old/1vs1-Marc/out/production/1vs1-Marc/plugin.yml
Normal file
11
Plugins/Old/1vs1-Marc/out/production/1vs1-Marc/plugin.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
name: 1vs1
|
||||
version: 1.0
|
||||
api-version: 1.8
|
||||
main: de.craftix.onevone.Main
|
||||
|
||||
commands:
|
||||
addworld:
|
||||
setspawn:
|
||||
saveworld:
|
||||
setlobby:
|
||||
stats:
|
||||
9
Plugins/Old/1vs1-Marc/src/de/craftix/onevone/MSG.java
Normal file
9
Plugins/Old/1vs1-Marc/src/de/craftix/onevone/MSG.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package de.craftix.onevone;
|
||||
|
||||
public class MSG {
|
||||
|
||||
public static final String onlyPlayer = "§cNur Spieler können diesen Command benutzen!";
|
||||
public static final String noPerm = "§cDu hast nicht genug Rechte, um diesen Command zu benutzen!";
|
||||
public static final String syntax = "§cFalscher Syntax!";
|
||||
|
||||
}
|
||||
71
Plugins/Old/1vs1-Marc/src/de/craftix/onevone/Main.java
Normal file
71
Plugins/Old/1vs1-Marc/src/de/craftix/onevone/Main.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package de.craftix.onevone;
|
||||
|
||||
import de.craftix.onevone.commands.*;
|
||||
import de.craftix.onevone.listener.onJoin;
|
||||
import de.craftix.onevone.listener.onLobby;
|
||||
import de.craftix.onevone.saving.*;
|
||||
import de.craftix.onevone.utils.*;
|
||||
import de.craftix.onevone.utils.kit.Kits;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
|
||||
public static ArrayList<FightWorld> worlds = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
MySQL.connect();
|
||||
SqlManager.createTables();
|
||||
|
||||
Kits.setup();
|
||||
|
||||
World lobby = Lobbymanager.getLobby();
|
||||
if (lobby != null) {
|
||||
lobby.setGameRuleValue("randomTickSpeed", "0");
|
||||
lobby.setGameRuleValue("doFireTick", "false");
|
||||
lobby.setGameRuleValue("doMobSpawning", "false");
|
||||
lobby.setGameRuleValue("doDaylightCycle", "false");
|
||||
lobby.setAnimalSpawnLimit(0);
|
||||
lobby.setMonsterSpawnLimit(0);
|
||||
lobby.setAutoSave(true);
|
||||
lobby.setDifficulty(Difficulty.PEACEFUL);
|
||||
}
|
||||
|
||||
getCommand("addworld").setExecutor(new AddWorld());
|
||||
getCommand("setspawn").setExecutor(new SetSpawn());
|
||||
getCommand("saveworld").setExecutor(new SaveWorld());
|
||||
getCommand("setlobby").setExecutor(new SetLobby());
|
||||
getCommand("stats").setExecutor(new Stats());
|
||||
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
pm.registerEvents(new onJoin(), this);
|
||||
pm.registerEvents(new onLobby(), this);
|
||||
pm.registerEvents(new Lobbymanager(), this);
|
||||
pm.registerEvents(new Gamemanager(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
MySQL.disconnect();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) p.kickPlayer("Server restart");
|
||||
for (Gamemanager games : Gamemanager.games){
|
||||
World map = games.map;
|
||||
Bukkit.unloadWorld(map, false);
|
||||
Gamemanager.deleteWorld(map.getWorldFolder());
|
||||
}
|
||||
}
|
||||
|
||||
public static FightWorld getWorld(String cName){
|
||||
for (FightWorld world : worlds){
|
||||
if (world.cName.equalsIgnoreCase(cName)) return world;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
8
Plugins/Old/1vs1-Marc/src/de/craftix/onevone/Perms.java
Normal file
8
Plugins/Old/1vs1-Marc/src/de/craftix/onevone/Perms.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package de.craftix.onevone;
|
||||
|
||||
public class Perms {
|
||||
|
||||
public static final String setup = "1vs1.setup";
|
||||
public static final String admin = "1vs1.admin";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package de.craftix.onevone.commands;
|
||||
|
||||
import de.craftix.onevone.MSG;
|
||||
import de.craftix.onevone.Main;
|
||||
import de.craftix.onevone.Perms;
|
||||
import de.craftix.onevone.utils.FightWorld;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AddWorld implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
if (sender instanceof Player){
|
||||
Player p = (Player) sender;
|
||||
if (p.hasPermission(Perms.setup)){
|
||||
if (args.length == 1){
|
||||
if (FightWorld.checkName(args[0])){
|
||||
FightWorld world = new FightWorld();
|
||||
world.cName = args[0];
|
||||
Main.worlds.add(world);
|
||||
p.sendMessage("§aDie Welt wurde erstellt!");
|
||||
}else {
|
||||
p.sendMessage("§cDieser Name ist bereits vergeben!");
|
||||
}
|
||||
}else {
|
||||
p.sendMessage(MSG.syntax);
|
||||
}
|
||||
}else {
|
||||
p.sendMessage(MSG.noPerm);
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(MSG.onlyPlayer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package de.craftix.onevone.commands;
|
||||
|
||||
import de.craftix.onevone.MSG;
|
||||
import de.craftix.onevone.Main;
|
||||
import de.craftix.onevone.Perms;
|
||||
import de.craftix.onevone.utils.FightWorld;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SaveWorld implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
if (sender instanceof Player){
|
||||
Player p = (Player) sender;
|
||||
if (p.hasPermission(Perms.setup)){
|
||||
if (args.length == 1){
|
||||
FightWorld world = Main.getWorld(args[0]);
|
||||
if (world != null){
|
||||
if (world.spawn1 != null && world.spawn2 != null && world.world != null && world.cName != null){
|
||||
FightWorld.saveWorld(world);
|
||||
p.sendMessage("§aDie Welt wurde erfolgreich gespeichert!");
|
||||
}else {
|
||||
p.sendMessage("§cDie Welt wurde noch nicht fertig konfiguriert!");
|
||||
}
|
||||
}else {
|
||||
p.sendMessage("§cDiese Welt existiert nicht!");
|
||||
}
|
||||
}else {
|
||||
p.sendMessage(MSG.syntax);
|
||||
}
|
||||
}else {
|
||||
p.sendMessage(MSG.noPerm);
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(MSG.onlyPlayer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package de.craftix.onevone.commands;
|
||||
|
||||
import de.craftix.onevone.MSG;
|
||||
import de.craftix.onevone.Perms;
|
||||
import de.craftix.onevone.saving.MySQL;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SetLobby implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
if (sender instanceof Player){
|
||||
Player p = (Player)sender;
|
||||
if (p.hasPermission(Perms.setup)){
|
||||
Location loc = p.getLocation();
|
||||
MySQL.insert("DELETE FROM lobby");
|
||||
String qry1 = "INSERT INTO lobby (World, x, y, z, yaw, pitch) VALUES (";
|
||||
String qry2 = "\"" + loc.getWorld().getName() + "\", \"" + loc.getX() + "\", \"" + loc.getY() + "\", \"" + loc.getZ() + "\", \"" + loc.getYaw() + "\", \"" + loc.getPitch() + "\")";
|
||||
MySQL.insert(qry1 + qry2);
|
||||
p.sendMessage("§aDie Lobby wurde gesetzt");
|
||||
}else p.sendMessage(MSG.noPerm);
|
||||
}else sender.sendMessage(MSG.onlyPlayer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package de.craftix.onevone.commands;
|
||||
|
||||
import de.craftix.onevone.MSG;
|
||||
import de.craftix.onevone.Main;
|
||||
import de.craftix.onevone.Perms;
|
||||
import de.craftix.onevone.utils.FightWorld;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SetSpawn implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
if (sender instanceof Player){
|
||||
Player p = (Player) sender;
|
||||
if (p.hasPermission(Perms.setup)){
|
||||
if (args.length == 2 && (args[1].equalsIgnoreCase("1") || args[1].equalsIgnoreCase("2"))){
|
||||
FightWorld world = Main.getWorld(args[0]);
|
||||
if(world != null){
|
||||
if (args[1].equalsIgnoreCase("1")){
|
||||
world.spawn1 = p.getLocation();
|
||||
}else {
|
||||
world.spawn2 = p.getLocation();
|
||||
}
|
||||
world.world = p.getLocation().getWorld();
|
||||
p.sendMessage("§aDer Spawn §6" + args[1] + " §awurde hinzugefügt");
|
||||
}else {
|
||||
p.sendMessage("§cDiese Welt existiert nicht!");
|
||||
}
|
||||
}else {
|
||||
p.sendMessage(MSG.syntax);
|
||||
}
|
||||
}else {
|
||||
p.sendMessage(MSG.noPerm);
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(MSG.onlyPlayer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package de.craftix.onevone.commands;
|
||||
|
||||
import de.craftix.onevone.MSG;
|
||||
import de.craftix.onevone.utils.Gamemanager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Stats implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
if (sender instanceof Player){
|
||||
Player p = (Player) sender;
|
||||
List<Integer> stats = Gamemanager.getStats(p);
|
||||
int wins = stats.get(0);
|
||||
int looses = stats.get(1);
|
||||
p.sendMessage("§6------------§bStats§6------------");
|
||||
p.sendMessage("§aGewonnene Matches: §e" + wins);
|
||||
p.sendMessage("§cVerlorene Matches: §e" + looses);
|
||||
p.sendMessage("§6-----------------------------");
|
||||
}else sender.sendMessage(MSG.onlyPlayer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package de.craftix.onevone.listener;
|
||||
|
||||
import de.craftix.onevone.utils.Gamemanager;
|
||||
import de.craftix.onevone.utils.Lobbymanager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class onJoin implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onJoinEvent(PlayerJoinEvent e){
|
||||
e.setJoinMessage(null);
|
||||
Location spawn = Lobbymanager.getSpawn();
|
||||
if (spawn != null) e.getPlayer().teleport(spawn);
|
||||
Lobbymanager.giveInv(e.getPlayer());
|
||||
if (Gamemanager.getStats(e.getPlayer()) == null){
|
||||
Gamemanager.setStats(e.getPlayer(), 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuitEvent(PlayerQuitEvent e){
|
||||
e.setQuitMessage(null);
|
||||
Player p = e.getPlayer();
|
||||
Gamemanager manager = null;
|
||||
for (Gamemanager game : Gamemanager.games){
|
||||
if (game.p1 == p || game.p2 == p) {
|
||||
manager = game;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (manager != null) Gamemanager.handleWinning(manager.map, manager, p);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package de.craftix.onevone.listener;
|
||||
|
||||
import de.craftix.onevone.saving.MySQL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
|
||||
public class onLobby implements Listener {
|
||||
|
||||
private World getLobby(){
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM lobby");
|
||||
rs.next();
|
||||
return Bukkit.getWorld(rs.getString("World"));
|
||||
}catch (Exception e) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent e){
|
||||
if (e.getBlock().getWorld().equals(getLobby())) e.setCancelled(true);
|
||||
else if (!e.getBlock().getType().equals(Material.SANDSTONE)) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBuild(BlockPlaceEvent e){
|
||||
if (e.getBlock().getWorld().equals(getLobby())) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e){
|
||||
try {
|
||||
if (e.getClickedBlock().getWorld().equals(getLobby())) e.setCancelled(true);
|
||||
}catch (Exception exception) {}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(EntityDamageEvent e){
|
||||
if (e.getEntity().getWorld().equals(getLobby())) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHunger(FoodLevelChangeEvent e){
|
||||
if (e.getEntity().getWorld().equals(getLobby())) {
|
||||
e.setCancelled(true);
|
||||
((Player) e.getEntity()).setFoodLevel(20);
|
||||
((Player) e.getEntity()).setSaturation(5);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInvClick(InventoryClickEvent e){
|
||||
if (e.getWhoClicked().getWorld().equals(getLobby())) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDrop(PlayerDropItemEvent e){
|
||||
if (e.getItemDrop().getWorld().equals(getLobby())) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPickUP(PlayerPickupItemEvent e){
|
||||
if (e.getItem().getWorld().equals(getLobby())) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWeatherChange(WeatherChangeEvent e){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMobSpawn(EntitySpawnEvent e){
|
||||
if (e.getEntity() instanceof Player) return;
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package de.craftix.onevone.saving;
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class MySQL {
|
||||
|
||||
public static final String server = "localhost";
|
||||
public static final Integer port = 3306;
|
||||
public static final String db = "CloudNet";
|
||||
public static final String user = "CloudNet";
|
||||
public static final String pass = "GXRD9geCHrUhF0c3";
|
||||
private static Connection con = null;
|
||||
|
||||
public static boolean connect(){
|
||||
String conString = "jdbc:mysql://" + server + ":" + port + "/" + db;
|
||||
try {
|
||||
con = DriverManager.getConnection(conString, user, pass);
|
||||
System.out.println("[1vs1] MySQL connected");
|
||||
return true;
|
||||
}catch (SQLException e){
|
||||
System.out.println("[1vs1] MySQL connection failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean disconnect(){
|
||||
if (!isConnected()) return true;
|
||||
try {
|
||||
con.close();
|
||||
con = null;
|
||||
System.out.println("[1vs1] MySQL disconnected");
|
||||
return true;
|
||||
}catch (SQLException e){
|
||||
System.out.println("[1vs1] MySQL disconnecting failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isConnected(){
|
||||
if (con == null) return false;
|
||||
else return true;
|
||||
}
|
||||
|
||||
public static void insert(String qry){
|
||||
try {
|
||||
con.prepareStatement(qry).executeUpdate();
|
||||
}catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static ResultSet getData(String qry){
|
||||
try {
|
||||
return con.prepareStatement(qry).executeQuery();
|
||||
}catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package de.craftix.onevone.saving;
|
||||
|
||||
public class SqlManager {
|
||||
|
||||
public static void createTables(){
|
||||
if (!MySQL.isConnected()) MySQL.connect();
|
||||
//World Presets
|
||||
MySQL.insert("CREATE TABLE IF NOT EXISTS worlds (Name VARCHAR(100), x1 VARCHAR(100), y1 VARCHAR(100), z1 VARCHAR(100), yaw1 VARCHAR(100), pitch1 VARCHAR(100), x2 VARCHAR(100), y2 VARCHAR(100), z2 VARCHAR(100), yaw2 VARCHAR(100), pitch2 VARCHAR(100), CName VARCHAR(100))");
|
||||
//Scores
|
||||
MySQL.insert("CREATE TABLE IF NOT EXISTS Stats (UUID VARCHAR(100), Wins INT(100), Looses INT(100))");
|
||||
//Lobby Data
|
||||
MySQL.insert("CREATE TABLE IF NOT EXISTS Kits (UUID VARCHAR(100), Kit INT(10))");
|
||||
//Lobby
|
||||
MySQL.insert("CREATE TABLE IF NOT EXISTS lobby (World VARCHAR(100), x VARCHAR(100), y VARCHAR(100), z VARCHAR(100), yaw VARCHAR(100), pitch VARCHAR(100))");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package de.craftix.onevone.utils;
|
||||
|
||||
import de.craftix.onevone.Main;
|
||||
import de.craftix.onevone.saving.MySQL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class FightWorld {
|
||||
|
||||
//static
|
||||
public static FightWorld getWorld(String cName) {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM worlds WHERE CName = \"" + cName + "\"");
|
||||
try {
|
||||
if (rs.next()){
|
||||
String x1 = rs.getString("x1");
|
||||
String y1 = rs.getString("y1");
|
||||
String z1 = rs.getString("z1");
|
||||
String yaw1 = rs.getString("yaw1");
|
||||
String pitch1 = rs.getString("pitch1");
|
||||
String x2 = rs.getString("x2");
|
||||
String y2 = rs.getString("y2");
|
||||
String z2 = rs.getString("z2");
|
||||
String yaw2 = rs.getString("yaw2");
|
||||
String pitch2 = rs.getString("pitch2");
|
||||
String world = rs.getString("Name");
|
||||
return new FightWorld(world, x1, y1, z1, yaw1, pitch1, x2, y2, z2, yaw2, pitch2, cName);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void saveWorld(FightWorld world){
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM worlds WHERE CName = \"" + world.cName + "\"");
|
||||
if (rs.next()) MySQL.insert("DELETE FROM worlds WHERE CName = \"" + world.cName + "\"");
|
||||
String name = world.world.getName();
|
||||
String x1 = String.valueOf(world.spawn1.getX());
|
||||
String y1 = String.valueOf(world.spawn1.getY());
|
||||
String z1 = String.valueOf(world.spawn1.getZ());
|
||||
String yaw1 = String.valueOf(world.spawn1.getYaw());
|
||||
String pitch1 = String.valueOf(world.spawn1.getPitch());
|
||||
String x2 = String.valueOf(world.spawn2.getX());
|
||||
String y2 = String.valueOf(world.spawn2.getY());
|
||||
String z2 = String.valueOf(world.spawn2.getZ());
|
||||
String yaw2 = String.valueOf(world.spawn2.getYaw());
|
||||
String pitch2 = String.valueOf(world.spawn2.getPitch());
|
||||
String qry1 = "INSERT INTO worlds (Name, x1, y1, z1, yaw1, pitch1, x2, y2, z2, yaw2, pitch2, CName) VALUES ";
|
||||
String qry2 = "(\"" + world.world.getName() + "\", ";
|
||||
String qry3 = "\"" + x1 + "\", \"" + y1 + "\", \"" + z1 + "\", \"" + yaw1 + "\", \"" + pitch1 + "\", ";
|
||||
String qry4 = "\"" + x2 + "\", \"" + y2 + "\", \"" + z2 + "\", \"" + yaw2 + "\", \"" + pitch2 + "\", \"" + world.cName + "\")";
|
||||
MySQL.insert(qry1 + qry2 + qry3 + qry4);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteWorld(String cName){
|
||||
MySQL.insert("DELETE FROM worlds WHERE CName = \"" + cName + "\"");
|
||||
}
|
||||
|
||||
public static boolean checkName(String cName){
|
||||
String ram = null;
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM worlds WHERE CName = \"" + cName + "\"");
|
||||
rs.next();
|
||||
try {
|
||||
ram = rs.getString("Name");
|
||||
}catch (Exception e){}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Main.getWorld(cName) == null && ram == null) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ArrayList<FightWorld> getAllWorlds(){
|
||||
ArrayList<FightWorld> worlds = new ArrayList<>();
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM worlds");
|
||||
try {
|
||||
while (rs.next()){
|
||||
String x1 = rs.getString("x1");
|
||||
String y1 = rs.getString("y1");
|
||||
String z1 = rs.getString("z1");
|
||||
String yaw1 = rs.getString("yaw1");
|
||||
String pitch1 = rs.getString("pitch1");
|
||||
String x2 = rs.getString("x2");
|
||||
String y2 = rs.getString("y2");
|
||||
String z2 = rs.getString("z2");
|
||||
String yaw2 = rs.getString("yaw2");
|
||||
String pitch2 = rs.getString("pitch2");
|
||||
String world = rs.getString("Name");
|
||||
String cName = rs.getString("CName");
|
||||
worlds.add(new FightWorld(world, x1, y1, z1, yaw1, pitch1, x2, y2, z2, yaw2, pitch2, cName));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return worlds;
|
||||
}
|
||||
|
||||
//nonStatic
|
||||
public Location spawn1;
|
||||
public Location spawn2;
|
||||
public World world;
|
||||
public String cName;
|
||||
|
||||
public FightWorld() {}
|
||||
public FightWorld(String world, String x1, String y1, String z1, String yaw1, String pitch1, String x2, String y2, String z2, String yaw2, String pitch2, String cName){
|
||||
this.world = Bukkit.getWorld(world);
|
||||
spawn1 = new Location(this.world, Double.valueOf(x1), Double.valueOf(y1), Double.valueOf(z1), Float.valueOf(yaw1), Float.valueOf(pitch1));
|
||||
spawn2 = new Location(this.world, Double.valueOf(x2), Double.valueOf(y2), Double.valueOf(z2), Float.valueOf(yaw2), Float.valueOf(pitch2));
|
||||
this.cName = cName;
|
||||
}
|
||||
public FightWorld(World world, Location spawn1, Location spawn2, String cName){
|
||||
this.world = world;
|
||||
this.cName = cName;
|
||||
this.spawn1 = spawn1;
|
||||
this.spawn2 = spawn2;
|
||||
}
|
||||
|
||||
public void setMap(World map){
|
||||
spawn1.setWorld(map);
|
||||
spawn2.setWorld(map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package de.craftix.onevone.utils;
|
||||
|
||||
import de.craftix.onevone.saving.MySQL;
|
||||
import de.craftix.onevone.utils.kit.Kits;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import java.io.*;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Gamemanager implements Listener {
|
||||
|
||||
public static ArrayList<Gamemanager> games = new ArrayList<>();
|
||||
|
||||
private static void copyFileStructure(File source, File target){
|
||||
try {
|
||||
ArrayList<String> ignore = new ArrayList<>(Arrays.asList("uid.dat", "session.lock"));
|
||||
if(!ignore.contains(source.getName())) {
|
||||
if(source.isDirectory()) {
|
||||
if(!target.exists())
|
||||
if (!target.mkdirs())
|
||||
throw new IOException("Couldn't create world directory!");
|
||||
String files[] = source.list();
|
||||
for (String file : files) {
|
||||
File srcFile = new File(source, file);
|
||||
File destFile = new File(target, file);
|
||||
copyFileStructure(srcFile, destFile);
|
||||
}
|
||||
} else {
|
||||
InputStream in = new FileInputStream(source);
|
||||
OutputStream out = new FileOutputStream(target);
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = in.read(buffer)) > 0)
|
||||
out.write(buffer, 0, length);
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Integer> getStats(Player p){
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM Stats WHERE UUID = \"" + p.getUniqueId().toString() + "\"");
|
||||
if (rs.next()){
|
||||
int wins = rs.getInt("Wins");
|
||||
int looses = rs.getInt("Looses");
|
||||
List<Integer> stats = new ArrayList<>();
|
||||
stats.add(wins);
|
||||
stats.add(looses);
|
||||
return stats;
|
||||
}
|
||||
}catch (Exception e) {}
|
||||
return null;
|
||||
}
|
||||
public static void setStats(Player p, int wins, int looses){
|
||||
MySQL.insert("DELETE FROM Stats WHERE UUID = \"" + p.getUniqueId().toString() + "\"");
|
||||
MySQL.insert("INSERT INTO Stats (UUID, Wins, Looses) VALUES (\"" + p.getUniqueId().toString() + "\", " + wins + ", " + looses + ")");
|
||||
}
|
||||
|
||||
public static void addWin(Player p){
|
||||
List<Integer> stats = getStats(p);
|
||||
setStats(p, stats.get(0) + 1, stats.get(1));
|
||||
}
|
||||
public static void addLoose(Player p){
|
||||
List<Integer> stats = getStats(p);
|
||||
setStats(p, stats.get(0), stats.get(1) + 1);
|
||||
}
|
||||
|
||||
public static void addGame(Player p1, Player p2, FightWorld preset){
|
||||
Gamemanager manager = new Gamemanager(p1, p2, preset);
|
||||
manager.startGame();
|
||||
games.add(manager);
|
||||
}
|
||||
|
||||
private static int getFreeGameID(){
|
||||
int i = 0;
|
||||
for (Gamemanager game : games){
|
||||
if (game.id == i) i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static boolean deleteWorld(File path){
|
||||
if(path.exists()) {
|
||||
File files[] = path.listFiles();
|
||||
for(int i=0; i<files.length; i++) {
|
||||
if(files[i].isDirectory()) {
|
||||
deleteWorld(files[i]);
|
||||
} else {
|
||||
files[i].delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
return(path.delete());
|
||||
}
|
||||
|
||||
//nonStatic
|
||||
public Player p1;
|
||||
public Player p2;
|
||||
public FightWorld preset;
|
||||
public World map;
|
||||
public int id;
|
||||
|
||||
public Gamemanager() {}
|
||||
public Gamemanager(Player p1, Player p2, FightWorld preset){
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
this.preset = preset;
|
||||
}
|
||||
|
||||
public void startGame(){
|
||||
id = getFreeGameID();
|
||||
copyFileStructure(preset.world.getWorldFolder(), new File(Bukkit.getWorldContainer(), preset.cName + "-" + id));
|
||||
new WorldCreator(preset.cName + "-" + id).createWorld();
|
||||
map = Bukkit.getWorld(preset.cName + "-" + id);
|
||||
preset.setMap(map);
|
||||
|
||||
//map settings
|
||||
map.setGameRuleValue("randomTickSpeed", "0");
|
||||
map.setGameRuleValue("doFireTick", "false");
|
||||
map.setGameRuleValue("doMobSpawning", "false");
|
||||
map.setGameRuleValue("doDaylightCycle", "false");
|
||||
map.setAnimalSpawnLimit(0);
|
||||
map.setMonsterSpawnLimit(0);
|
||||
map.setAutoSave(false);
|
||||
map.setDifficulty(Difficulty.NORMAL);
|
||||
for (Entity e : map.getEntities()){
|
||||
if (e instanceof Player) continue;
|
||||
e.remove();
|
||||
}
|
||||
|
||||
p1.teleport(preset.spawn1);
|
||||
p2.teleport(preset.spawn2);
|
||||
Kits.preparePlayer(Lobbymanager.getKittype(p1), p1);
|
||||
Kits.preparePlayer(Lobbymanager.getKittype(p2), p2);
|
||||
p1.sendMessage("§aDein gegner hat das kit §6" + Lobbymanager.getKittype(p2).name() + " §agewählt");
|
||||
p2.sendMessage("§aDein gegner hat das kit §6" + Lobbymanager.getKittype(p1).name() + " §agewählt");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent event){
|
||||
try {
|
||||
for (Gamemanager manager : games){
|
||||
if (event.getEntity().getWorld().equals(manager.map)){
|
||||
event.setDeathMessage(null);
|
||||
event.setKeepInventory(true);
|
||||
handleWinning(event.getEntity().getWorld(), manager, event.getEntity());
|
||||
break;
|
||||
}
|
||||
}
|
||||
Location spawn = Lobbymanager.getSpawn();
|
||||
spawn.setY(spawn.getY() + 1);
|
||||
event.getEntity().spigot().respawn();
|
||||
event.getEntity().teleport(spawn);
|
||||
}catch (Exception e) {}
|
||||
}
|
||||
|
||||
public static void handleWinning(World world, Gamemanager manager, Player looser){
|
||||
try {
|
||||
Location spawn = Lobbymanager.getSpawn();
|
||||
spawn.setY(spawn.getY() + 1);
|
||||
for (Player p : world.getPlayers()){
|
||||
if (!p.getUniqueId().equals(looser.getUniqueId())){
|
||||
p.sendMessage("§aDu hast den Kampf gewonnen");
|
||||
looser.spigot().respawn();
|
||||
looser.teleport(spawn);
|
||||
Lobbymanager.giveInv(looser);
|
||||
addLoose(looser);
|
||||
looser.sendMessage("§6" + p.getDisplayName() + " §ahatte noch §b" + ((int)p.getHealth() / 2) + " §aHerzen");
|
||||
p.teleport(spawn);
|
||||
Lobbymanager.giveInv(p);
|
||||
addWin(p);
|
||||
}
|
||||
}
|
||||
Bukkit.unloadWorld(world, false);
|
||||
deleteWorld(world.getWorldFolder());
|
||||
games.remove(manager);
|
||||
}catch (Exception e){}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
package de.craftix.onevone.utils;
|
||||
|
||||
import de.craftix.onevone.saving.MySQL;
|
||||
import de.craftix.onevone.utils.kit.Kit;
|
||||
import de.craftix.onevone.utils.kit.Kits;
|
||||
import de.craftix.onevone.utils.kit.Kittype;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
public class Lobbymanager implements Listener {
|
||||
|
||||
public static World getLobby(){
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM lobby");
|
||||
rs.next();
|
||||
return Bukkit.getWorld(rs.getString("World"));
|
||||
}catch (Exception e) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Location getSpawn(){
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM lobby");
|
||||
rs.next();
|
||||
String x = rs.getString("x");
|
||||
String y = rs.getString("y");
|
||||
String z = rs.getString("z");
|
||||
String yaw = rs.getString("yaw");
|
||||
String pitch = rs.getString("pitch");
|
||||
String world = rs.getString("world");
|
||||
Location loc = new Location(Bukkit.getWorld(world), Double.valueOf(x), Double.valueOf(y), Double.valueOf(z), Float.valueOf(yaw), Float.valueOf(pitch));
|
||||
return loc;
|
||||
}catch (Exception exception){}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void giveInv(Player p){
|
||||
p.getInventory().clear();
|
||||
p.getInventory().setHelmet(null);
|
||||
p.getInventory().setChestplate(null);
|
||||
p.getInventory().setLeggings(null);
|
||||
p.getInventory().setBoots(null);
|
||||
p.setHealth(20);
|
||||
|
||||
ItemStack selectKit = new ItemStack(Material.DIAMOND_SWORD);
|
||||
ItemMeta sKitMeta = selectKit.getItemMeta();
|
||||
sKitMeta.setDisplayName("§eKit wählen");
|
||||
selectKit.setItemMeta(sKitMeta);
|
||||
|
||||
p.getInventory().setItem(4, selectKit);
|
||||
}
|
||||
|
||||
public static Kittype getKittype(Player p){
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM Kits WHERE UUID = \"" + p.getUniqueId() + "\"");
|
||||
if (rs.next()){
|
||||
int kit = rs.getInt("Kit");
|
||||
return Kits.getTypeByID(kit);
|
||||
}
|
||||
}catch (Exception e){}
|
||||
return Kittype.RANDOM;
|
||||
}
|
||||
|
||||
private static void saveKit(Kittype type, Player p){
|
||||
MySQL.insert("DELETE FROM Kits WHERE UUID = \"" + p.getUniqueId() + "\"");
|
||||
MySQL.insert("INSERT INTO Kits (UUID, Kit) VALUES (\"" + p.getUniqueId() + "\", " + Kits.getKitID(type) + ")");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e){
|
||||
if (!e.getPlayer().getWorld().equals(getLobby())) return;
|
||||
e.setCancelled(true);
|
||||
if (e.getMaterial().equals(Material.DIAMOND_SWORD)) openKitGUI(e.getPlayer());
|
||||
}
|
||||
|
||||
private static final String guiName = "§6§lKits";
|
||||
|
||||
public static void openKitGUI(Player p){
|
||||
Inventory inv = Bukkit.createInventory(null, 3*9, guiName);
|
||||
for (int slot = 0; slot < inv.getSize(); slot++){
|
||||
ItemStack glass = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
||||
ItemMeta glassMeta = glass.getItemMeta();
|
||||
glassMeta.setDisplayName(" ");
|
||||
glass.setItemMeta(glassMeta);
|
||||
inv.setItem(slot, glass);
|
||||
}
|
||||
|
||||
ItemStack random = new ItemStack(Material.NETHER_STAR);
|
||||
ItemMeta randomMeta = random.getItemMeta();
|
||||
randomMeta.setDisplayName("§eRANDOM");
|
||||
random.setItemMeta(randomMeta);
|
||||
inv.setItem(inv.getSize() - 1, random);
|
||||
|
||||
int slot = 0;
|
||||
for (Kit kit : Kits.kits){
|
||||
inv.setItem(slot, kit.invItem);
|
||||
slot++;
|
||||
}
|
||||
|
||||
p.openInventory(inv);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInvClick(InventoryClickEvent e){
|
||||
try {
|
||||
if (!e.getView().getTitle().equals(guiName)) return;
|
||||
String item = e.getCurrentItem().getItemMeta().getDisplayName();
|
||||
if (item.equals("§eRANDOM")){
|
||||
saveKit(Kittype.RANDOM, (Player) e.getWhoClicked());
|
||||
e.getWhoClicked().sendMessage("§aDu hast das Kit " + item + " §agewählt");
|
||||
e.getWhoClicked().closeInventory();
|
||||
return;
|
||||
}
|
||||
for (Kit kit : Kits.kits){
|
||||
if (kit.invItem.getItemMeta().getDisplayName().equals(item)){
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
if (p.hasPermission(kit.permission)){
|
||||
saveKit(kit.type, (Player) e.getWhoClicked());
|
||||
e.getWhoClicked().sendMessage("§aDu hast das Kit " + item + " §agewählt");
|
||||
}else {
|
||||
p.sendMessage("§cDu darfts dieses Kit nicht benutzen!");
|
||||
}
|
||||
e.getWhoClicked().closeInventory();
|
||||
}
|
||||
}
|
||||
}catch (Exception exception) {}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteractEntity(PlayerInteractEntityEvent e){
|
||||
if (!e.getPlayer().getWorld().equals(getLobby())) return;
|
||||
if (e.getPlayer().getInventory().getHeldItemSlot() == 4) return;
|
||||
if (!(e.getRightClicked() instanceof Player)) return;
|
||||
Player req = e.getPlayer();
|
||||
Player t = (Player) e.getRightClicked();
|
||||
|
||||
Acception acc = Acception.getAcception(t, req);
|
||||
if (acc == null) {
|
||||
if (Acception.getAcception(req, t) == null){
|
||||
new Acception(req, t);
|
||||
}
|
||||
}else {
|
||||
Acception.acceptions.remove(acc);
|
||||
ArrayList<Acception> as = new ArrayList<>();
|
||||
for (Acception a : Acception.acceptions){
|
||||
if (a.requester == req) as.add(a);
|
||||
else if (a.target == req) as.add(a);
|
||||
else if (a.requester == t) as.add(a);
|
||||
else if (a.target == t) as.add(a);
|
||||
}
|
||||
for (Acception a : as){
|
||||
Acception.acceptions.remove(a);
|
||||
}
|
||||
openWorldGUI(t, req);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String worldGUIName = "§a§lMap auswählen";
|
||||
|
||||
public static void openWorldGUI(Player p, Player p2){
|
||||
Inventory inv = Bukkit.createInventory(null, 3*9, worldGUIName);
|
||||
|
||||
for (int slot = 0; slot < inv.getSize(); slot++){
|
||||
ItemStack glass = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
|
||||
ItemMeta glassMeta = glass.getItemMeta();
|
||||
glassMeta.setDisplayName(" ");
|
||||
glass.setItemMeta(glassMeta);
|
||||
inv.setItem(slot, glass);
|
||||
}
|
||||
|
||||
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
|
||||
SkullMeta skullMeta = (SkullMeta)skull.getItemMeta();
|
||||
skullMeta.setOwner(p2.getName());
|
||||
skullMeta.setDisplayName("§cGegner: " + p2.getDisplayName());
|
||||
skull.setItemMeta(skullMeta);
|
||||
inv.setItem(4, skull);
|
||||
|
||||
try {
|
||||
int slot = 9;
|
||||
for (FightWorld world : FightWorld.getAllWorlds()){
|
||||
if (slot >= inv.getSize() - 2) break;
|
||||
ItemStack w = new ItemStack(Material.GRASS);
|
||||
ItemMeta wMeta = w.getItemMeta();
|
||||
wMeta.setDisplayName(world.cName);
|
||||
w.setItemMeta(wMeta);
|
||||
inv.setItem(slot, w);
|
||||
slot++;
|
||||
}
|
||||
}catch (Exception e) {}
|
||||
|
||||
ItemStack random = new ItemStack(Material.NETHER_STAR);
|
||||
ItemMeta randomMeta = random.getItemMeta();
|
||||
randomMeta.setDisplayName("§eRANDOM");
|
||||
random.setItemMeta(randomMeta);
|
||||
inv.setItem(inv.getSize() - 1, random);
|
||||
|
||||
p.openInventory(inv);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldGUIClick(InventoryClickEvent e){
|
||||
try {
|
||||
if (!e.getView().getTitle().equals(worldGUIName)) return;
|
||||
e.setCancelled(true);
|
||||
Player p2 = Bukkit.getPlayer(((SkullMeta)e.getClickedInventory().getItem(4).getItemMeta()).getOwner());
|
||||
if (e.getCurrentItem().getType().equals(Material.NETHER_STAR)){
|
||||
ArrayList<FightWorld> worlds = FightWorld.getAllWorlds();
|
||||
int rand = new Random().nextInt(worlds.size() - 1);
|
||||
createGame((Player) e.getWhoClicked(), p2, worlds.get(rand));
|
||||
}
|
||||
if (!e.getCurrentItem().getType().equals(Material.GRASS)) return;
|
||||
String map = e.getCurrentItem().getItemMeta().getDisplayName();
|
||||
createGame((Player) e.getWhoClicked(), p2, FightWorld.getWorld(map));
|
||||
}catch (Exception exception){}
|
||||
}
|
||||
|
||||
public static void createGame(Player p1, Player p2, FightWorld preset){
|
||||
Gamemanager.addGame(p1, p2, preset);
|
||||
}
|
||||
}
|
||||
|
||||
class Acception {
|
||||
public static ArrayList<Acception> acceptions = new ArrayList<>();
|
||||
|
||||
public static Acception getAcception(Player req, Player t){
|
||||
for (Acception a : acceptions){
|
||||
if (a.target == t && a.requester == req) return a;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Player requester;
|
||||
public Player target;
|
||||
|
||||
public Acception(Player req, Player t){
|
||||
requester = req;
|
||||
target = t;
|
||||
t.sendMessage("§6" + requester.getDisplayName() + " §ahat dich herausgefordert. Klicke ihn an, um die Herausforderung anzunehmen");
|
||||
req.sendMessage("§aDu hast §6" + target.getDisplayName() + " §aherausgefordert. Warte, bis er sie annimmt...");
|
||||
acceptions.add(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package de.craftix.onevone.utils.kit;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Kit {
|
||||
|
||||
public HashMap<Integer, ItemStack> items = new HashMap<>();
|
||||
public ItemStack helmet;
|
||||
public ItemStack chestplate;
|
||||
public ItemStack leggins;
|
||||
public ItemStack boots;
|
||||
public Kittype type;
|
||||
public ItemStack invItem;
|
||||
public String permission;
|
||||
|
||||
public Kit(Kittype type){
|
||||
this.type = type;
|
||||
permission = "1vs1.kit." + type.name().toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
165
Plugins/Old/1vs1-Marc/src/de/craftix/onevone/utils/kit/Kits.java
Normal file
165
Plugins/Old/1vs1-Marc/src/de/craftix/onevone/utils/kit/Kits.java
Normal file
@@ -0,0 +1,165 @@
|
||||
package de.craftix.onevone.utils.kit;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class Kits {
|
||||
|
||||
public static ArrayList<Kit> kits = new ArrayList<>();
|
||||
|
||||
public static void setup(){
|
||||
//UHC
|
||||
Kit uhc = new Kit(Kittype.UHC);
|
||||
uhc.items.put(6, new ItemStack(Material.SANDSTONE, 64));
|
||||
uhc.items.put(7, new ItemStack(Material.SANDSTONE, 64));
|
||||
uhc.items.put(4, new ItemStack(Material.LAVA_BUCKET));
|
||||
uhc.items.put(13, new ItemStack(Material.LAVA_BUCKET));
|
||||
uhc.items.put(5, new ItemStack(Material.WATER_BUCKET));
|
||||
uhc.items.put(14, new ItemStack(Material.WATER_BUCKET));
|
||||
uhc.items.put(1, new ItemStack(Material.BOW));
|
||||
uhc.items.put(9, new ItemStack(Material.ARROW, 16));
|
||||
ItemStack uhcSword = new ItemStack(Material.DIAMOND_SWORD);
|
||||
uhcSword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
|
||||
uhc.items.put(0, uhcSword);
|
||||
uhc.items.put(3, new ItemStack(Material.GOLDEN_APPLE, 4));
|
||||
uhc.items.put(8, new ItemStack(Material.COOKED_BEEF, 32));
|
||||
uhc.items.put(2, new ItemStack(Material.FISHING_ROD));
|
||||
uhc.helmet = new ItemStack(Material.IRON_HELMET);
|
||||
uhc.chestplate = new ItemStack(Material.IRON_CHESTPLATE);
|
||||
uhc.leggins = new ItemStack(Material.IRON_LEGGINGS);
|
||||
uhc.boots = new ItemStack(Material.IRON_BOOTS);
|
||||
uhc.invItem = createInvItem(Material.GOLDEN_APPLE, "§eUHC");
|
||||
kits.add(uhc);
|
||||
//OP
|
||||
Kit op = new Kit(Kittype.OP);
|
||||
ItemStack opHelmet = new ItemStack(Material.DIAMOND_HELMET);
|
||||
opHelmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
|
||||
ItemStack opChestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
|
||||
opChestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
|
||||
ItemStack opLeggins = new ItemStack(Material.DIAMOND_LEGGINGS);
|
||||
opLeggins.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
|
||||
ItemStack opBoots = new ItemStack(Material.DIAMOND_BOOTS);
|
||||
opBoots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
|
||||
op.helmet = opHelmet;
|
||||
op.chestplate = opChestplate;
|
||||
op.leggins = opLeggins;
|
||||
op.boots = opBoots;
|
||||
op.items.put(8, new ItemStack(Material.COOKED_BEEF, 32));
|
||||
ItemStack opSword = new ItemStack(Material.WOOD_SWORD);
|
||||
opSword.addEnchantment(Enchantment.DURABILITY, 1);
|
||||
op.items.put(0, opSword);
|
||||
op.invItem = createInvItem(Material.COMMAND, "§cOP");
|
||||
kits.add(op);
|
||||
//SG
|
||||
Kit sg = new Kit(Kittype.SG);
|
||||
sg.helmet = new ItemStack(Material.IRON_HELMET);
|
||||
sg.chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
|
||||
sg.leggins = new ItemStack(Material.DIAMOND_LEGGINGS);
|
||||
sg.boots = new ItemStack(Material.IRON_BOOTS);
|
||||
ItemStack sgSword = new ItemStack(Material.IRON_SWORD);
|
||||
sgSword.addEnchantment(Enchantment.DAMAGE_ALL, 3);
|
||||
sg.items.put(0, sgSword);
|
||||
sg.items.put(8, new ItemStack(Material.COOKED_BEEF, 32));
|
||||
sg.items.put(4, new ItemStack(Material.GOLDEN_APPLE, 4));
|
||||
sg.items.put(2, new ItemStack(Material.FISHING_ROD));
|
||||
ItemStack sgBow = new ItemStack(Material.BOW);
|
||||
sgBow.addEnchantment(Enchantment.ARROW_DAMAGE, 1);
|
||||
sg.items.put(1, sgBow);
|
||||
sg.items.put(9, new ItemStack(Material.ARROW, 4));
|
||||
sg.invItem = createInvItem(Material.FISHING_ROD, "§eSG");
|
||||
kits.add(sg);
|
||||
//TANK
|
||||
Kit tank = new Kit(Kittype.TANK);
|
||||
ItemStack tankHelmet = new ItemStack(Material.IRON_HELMET);
|
||||
tankHelmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
|
||||
ItemStack tankChestplate = new ItemStack(Material.IRON_CHESTPLATE);
|
||||
tankChestplate.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3);
|
||||
ItemStack tankLeggins = new ItemStack(Material.IRON_LEGGINGS);
|
||||
tankLeggins.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
|
||||
ItemStack tankBoots = new ItemStack(Material.IRON_BOOTS);
|
||||
tankBoots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
|
||||
tank.helmet = tankHelmet;
|
||||
tank.chestplate = tankChestplate;
|
||||
tank.leggins = tankLeggins;
|
||||
tank.boots = tankBoots;
|
||||
tank.items.put(8, new ItemStack(Material.COOKED_BEEF, 32));
|
||||
ItemStack tankSword = new ItemStack(Material.STONE_SWORD);
|
||||
tankSword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
|
||||
tank.items.put(0, tankSword);
|
||||
tank.invItem = createInvItem(Material.IRON_CHESTPLATE, "§eTANK");
|
||||
kits.add(tank);
|
||||
}
|
||||
|
||||
public static Kit getKit(Kittype type){
|
||||
for (Kit kit : kits){
|
||||
if (kit.type == type) return kit;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Kittype getTypeByID(int id){
|
||||
//0 = RANDOM
|
||||
if (id == 0) return Kittype.RANDOM;
|
||||
//1 = UHC
|
||||
if (id == 1) return Kittype.UHC;
|
||||
//2 = OP
|
||||
if (id == 2) return Kittype.OP;
|
||||
//3 = SG
|
||||
if (id == 3) return Kittype.SG;
|
||||
//4 = TANK
|
||||
if (id == 4) return Kittype.TANK;
|
||||
return Kittype.RANDOM;
|
||||
}
|
||||
|
||||
public static int getKitID(Kittype type){
|
||||
if (type == Kittype.RANDOM) return 0;
|
||||
if (type == Kittype.UHC) return 1;
|
||||
if (type == Kittype.OP) return 2;
|
||||
if (type == Kittype.SG) return 3;
|
||||
if (type == Kittype.TANK) return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void setItems(Kit kit, Player p){
|
||||
p.getInventory().setHelmet(kit.helmet);
|
||||
p.getInventory().setChestplate(kit.chestplate);
|
||||
p.getInventory().setLeggings(kit.leggins);
|
||||
p.getInventory().setBoots(kit.boots);
|
||||
for (int slot : kit.items.keySet()){
|
||||
p.getInventory().setItem(slot, kit.items.get(slot));
|
||||
}
|
||||
p.getInventory().setHeldItemSlot(0);
|
||||
}
|
||||
|
||||
public static void preparePlayer(Kittype kit, Player p){
|
||||
p.getInventory().setHelmet(null);
|
||||
p.getInventory().setChestplate(null);
|
||||
p.getInventory().setLeggings(null);
|
||||
p.getInventory().setBoots(null);
|
||||
p.getInventory().clear();
|
||||
if (kit == Kittype.RANDOM){
|
||||
List<Kit> allowedKits = new ArrayList<>();
|
||||
for (Kit k : kits){
|
||||
if (p.hasPermission(k.permission)) allowedKits.add(k);
|
||||
}
|
||||
int rand = new Random().nextInt(allowedKits.size() - 1);
|
||||
setItems(allowedKits.get(rand), p);
|
||||
}else setItems(getKit(kit), p);
|
||||
}
|
||||
|
||||
private static ItemStack createInvItem(Material type, String name){
|
||||
ItemStack item = new ItemStack(type);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(name);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package de.craftix.onevone.utils.kit;
|
||||
|
||||
public enum Kittype {
|
||||
UHC,
|
||||
OP,
|
||||
SG,
|
||||
TANK,
|
||||
RANDOM
|
||||
}
|
||||
11
Plugins/Old/1vs1-Marc/src/plugin.yml
Normal file
11
Plugins/Old/1vs1-Marc/src/plugin.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
name: 1vs1
|
||||
version: 1.0
|
||||
api-version: 1.8
|
||||
main: de.craftix.onevone.Main
|
||||
|
||||
commands:
|
||||
addworld:
|
||||
setspawn:
|
||||
saveworld:
|
||||
setlobby:
|
||||
stats:
|
||||
Reference in New Issue
Block a user