You are not logged in.

  • Login
Bitte besucht unser neues Forum unter https://forum.nitrado.net | Please visit our new Forum at https://forum.nitrado.net

Dear visitor, welcome to Nitrado.net Prepaid Gameserver Community-Support - Archiv. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

XemsDoom

User / Kunde

  • "XemsDoom" is male
  • "XemsDoom" started this thread

Posts: 758

Location: Zurich

Occupation: Sidekick

  • Send private message

1

Tuesday, February 5th 2013, 8:49pm

[SpoutServer] Votify - Vote-mechanism for your Spout server


This plugin activates a little server on your Spout server which waits for incoming votes, such as those coming from server-listing sites. It uses a 2048-RSA encryption for client-server communication.
Installation:
Just drop the downloaded JAR file into your plugins folder. Let the plugin run once by starting up the server and stopping it again. Then, configure the configuration.yml file.
The only thing to adjust is the port on which Votify will listen for incoming votes. Make sure to select a port which is free for use and might not be blocked by your hoster or another application.


For any additional informations please read the wiki.


VotifyListeners:
  • LogVotify - Logs votes.
  • EcoListener - Deposits a in the configuration file defined amount to the user who voted.

Developers:

Maven repository


Source code

1
2
3
4
5
6
7
8
9
10
11
<repository>
<id>xem-repo</id>
<url>http://repo.xemsdoom.com</url>
</repository>


<dependency>
<groupId>com.xemsdoom</groupId>
<artifactId>votify</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

HasteBin without limit: Xems' Hastebin

This post has been edited 1 times, last edit by "XemsDoom" (Feb 5th 2013, 9:03pm)


XemsDoom

User / Kunde

  • "XemsDoom" is male
  • "XemsDoom" started this thread

Posts: 758

Location: Zurich

Occupation: Sidekick

  • Send private message

2

Tuesday, February 5th 2013, 8:51pm

Create an own VotifyListener


You can create your own listeners very easily. Create a YourVotifyListener.java file by using an editor such as Notepad++. Then you paste the code below for a basic behavior. Make sure to rename YourVotifyListener to a name which fits your listener's task, if for example your listener will give the user who voted money, you might call it EcoVoteListener or so on.


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import com.xemsdoom.votify.vote.*;
import com.xemsdoom.votify.listeners.*;

public class YourVotifyListener implements VotifyListener {

    public void proccessVote(Vote vote) {
        System.out.println("Received: " + vote);
    }

    public void onEnable() {
        System.out.println("[YourVotifyListener] Enabled");
    }

    public void onDisable() {
        System.out.println("[YourVotifyListener] Disabled");
    }



If you aren't a developer and are screaming: "What in the heck is the meaning of the code?", so please contact a developer who might be so kind to write the listener for you.
If you are a developer and if you are crying at this moment that your server-administrator friend will come soon and ask you the above question: "We have a hard life" - XemsDoom.
  • The processVote(Vote vote) method is automatically called on each Vote coming from a service site. You don't have to worry about thread-safety at this point, because the processVote method is called by the main-server thread, but please remember you aren't safe if you start your own threads in proccessVote.
  • The onEnable() method is called when your listener was instantiated and activated by Votify. You might want to do some configurations in that method.
  • The onDisable() method is called when Votify is getting disabled.



Compile the VotifyListener


If you are again not a developer, ask a developer friend for compiling the listener.
In order to compile your own VotifyListener go to your console and include Votify.jar(or however it is called in your place) in the compilation command:


Source code

1
javac -cp Votify.jar YourVotifyListener.java



Note: If you have to add more dependencies, you can separate them with a semicolon (";"):


Source code

1
javac -cp Votify.jar;SpoutAPI.jar YourVotifyListener.java



After you have compiled the listener to a YourVotifyListener.class file, you can simply drop it into the "plugins/Votify/listeners" folder and it will load on the next server startup.
Done!


Here is a little bigger VotifyListener:

Spoiler Spoiler

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import java.io.File;
import java.io.IOException;

import org.spout.api.Spout;
import org.spout.api.event.EventHandler;
import org.spout.api.event.Listener;
import org.spout.api.event.server.service.ServiceEvent;
import org.spout.api.exception.ConfigurationException;
import org.spout.api.plugin.ServiceProvider;
import org.spout.api.plugin.services.EconomyService;
import org.spout.api.util.config.ConfigurationNode;
import org.spout.api.util.config.yaml.YamlConfiguration;

import com.xemsdoom.votify.listeners.VotifyListener;
import com.xemsdoom.votify.vote.Vote;

public class EcoListener implements VotifyListener, Listener {

    static {
        new File("plugins/Votify/listeners/EcoListener").mkdirs();
    }

    private YamlConfiguration config;
    private EconomyService ecoService;
    private boolean isEcoServiceInitialized = false;
    private double depositAmount;

    @Override
    public void onEnable() {
        createConfig();
        Spout.getEngine().getEventManager().registerEvents(this, this);
        System.out.println("[EcoListener] Enabled v1.0");
    }

    @Override
    public void onDisable() {
        System.out.println("[EcoListener] Disabled v1.0");
    }

    private void createConfig() {

        File configFile = new File("plugins/Votify/listeners/EcoListener", "config.yml");
        boolean didExist = true;

        if (!configFile.exists()) {
            try {
                configFile.createNewFile();
                didExist = false;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        config = new YamlConfiguration(configFile);

        // Write configuration
        if (!didExist) {
            ConfigurationNode node = new ConfigurationNode(config, new String[] { "AmountToDeposit" }, 50.00);
            config.setHeader("EcoListener v1.0 - Set the amount of money to deposit on a vote");
            config.setNode(node);
            try {
                config.save();
            } catch (ConfigurationException e) {
                e.printStackTrace();
            }
        }

        // Get amount to depost on a vote
        depositAmount = Math.round(config.getNode("AmountToDeposit").getDouble() * 100) / 100;
    }

    @EventHandler
    public void serviceEvent(ServiceEvent event) {

        if(isEcoServiceInitialized){
            return;
        }

        ServiceProvider<?> service = event.getProvider();

        if (service.getService().equals(EconomyService.class)) {    
            ecoService = (EconomyService) service.getProvider();
            isEcoServiceInitialized = true;
        }
    }

    @Override
    public void proccessVote(Vote vote) {

        // Get username of the user who voted
        String username = vote.getUsername();

        // Check if an EconomyService was even initialized
        if(ecoService == null){
            return;
        }

        // Check if account exists of the corresponding username
        if(!ecoService.exists(username)){
            return;
        }

        ecoService.deposit(username.trim(), depositAmount);
    }

}

HasteBin without limit: Xems' Hastebin

This post has been edited 2 times, last edit by "XemsDoom" (Feb 5th 2013, 9:10pm)


Maddin1436

User / Kunde

  • "Maddin1436" is male

Posts: 2,589

Location: Dresden

Occupation: Software- and System Design Engineer

Thanks: 7

  • Send private message

3

Tuesday, February 5th 2013, 9:01pm

Gute Arbeit ;) , werde es demnächst mal auf meinem neuen Server einsetzen ^^

XemsDoom

User / Kunde

  • "XemsDoom" is male
  • "XemsDoom" started this thread

Posts: 758

Location: Zurich

Occupation: Sidekick

  • Send private message

4

Tuesday, February 5th 2013, 9:02pm

Gute Arbeit ;) , werde es demnächst mal auf meinem neuen Server einsetzen ^^
Das Plugin ist für die Spout Platform, nichts da mit Bukkit.
HasteBin without limit: Xems' Hastebin

Maddin1436

User / Kunde

  • "Maddin1436" is male

Posts: 2,589

Location: Dresden

Occupation: Software- and System Design Engineer

Thanks: 7

  • Send private message

5

Tuesday, February 5th 2013, 9:04pm

Ich habe einen großen Spout server :P. Bzw. Baue ihn gerade auf

XemsDoom

User / Kunde

  • "XemsDoom" is male
  • "XemsDoom" started this thread

Posts: 758

Location: Zurich

Occupation: Sidekick

  • Send private message

6

Tuesday, February 5th 2013, 9:08pm

Mit SpoutServer meine ich nicht ein Craftbukkit Server + SpoutPlugin, sondern ein SpoutServer, ohne Minecraft/Bukkit Code.
HasteBin without limit: Xems' Hastebin

Maddin1436

User / Kunde

  • "Maddin1436" is male

Posts: 2,589

Location: Dresden

Occupation: Software- and System Design Engineer

Thanks: 7

  • Send private message

7

Tuesday, February 5th 2013, 9:10pm

Okay, also es giebt noch einen reinen Spoutserver, nur mit der SpoutAPI?

XemsDoom

User / Kunde

  • "XemsDoom" is male
  • "XemsDoom" started this thread

Posts: 758

Location: Zurich

Occupation: Sidekick

  • Send private message

8

Tuesday, February 5th 2013, 9:21pm

Das Spout Team welches das SpoutPlugin geschrieben haben, entwickeln seit vorletztem Jahr eine eigene Voxel-Engine. Sie haben eine API namens SpoutAPI entwickelt, welche durch den SpoutServer und dem SpoutClient implementiert werden. Es gibt also tatsächlich einen SpoutServer, der hat jedoch absolut gar Nichts mit Minecraft zu tun, in der Tat, du installierst Spiele mit Plugins. Es gibt ein Plugin für den SpoutServer namens "Vanilla", dieses Plugin ist Minecraft und wenn du es mit dem SpoutServer einsetzt, hast du einen Minecraft Server. Was speziell ist bei SpoutServer/Vanilla(kurz S/V) ist, dass alles Costum ist, sprich es ist kein Problem neue Mobs oder Blöcke hinzuzufügen.

Lader dir mal: das und das herunter.
Starte einfach mal die spout JAR ohne Vanilla mit der gleichen Batch wie du Craftbukkit startest(jedoch halt mit dem angepassten Namen), dann stoppe den Server und füge vanilla JAR in den generierten plugins Ordner. Neustarten, wieder stoppen, jetzt ladest du noch xEco(breakt in den nächsten Stunden kurz wegen ner API Change) oder Votify herunter und tust es ebenfalls in den plugins Ordner.
HasteBin without limit: Xems' Hastebin

This post has been edited 1 times, last edit by "XemsDoom" (Feb 5th 2013, 9:31pm)


daniel0916

User / Kunde

Posts: 998

  • Send private message

9

Tuesday, February 5th 2013, 10:35pm

Was ist dabei der Unterschied zum Spoutplugin bei Bukkit? Da kann man auch eigene Blöcke erstellen.

Was meinst du mit 'Costum ist'?
Kann man in dem normalen Bukkitplugin das nicht auch machen?

XemsDoom

User / Kunde

  • "XemsDoom" is male
  • "XemsDoom" started this thread

Posts: 758

Location: Zurich

Occupation: Sidekick

  • Send private message

10

Tuesday, February 5th 2013, 10:43pm

Was ist dabei der Unterschied zum Spoutplugin bei Bukkit? Da kann man auch eigene Blöcke erstellen.

Was meinst du mit 'Costum ist'?
Kann man in dem normalen Bukkitplugin das nicht auch machen?
Ja man kann mit SpoutPlugin + Spoutcraft auch eigene Blöcke/Items machen, jedoch ist das alles andere als performant, weil der ganze Code in den Server injected wird zur Laufzeit und Bukkit an sich schon extrem scheisse Läuft. Die machen einen neuen Server von Grund auf, parallel threaded ohne Notch Code. Ausserdem kannst du neue Mobs hinzufügen, ohne das du einen Client-Mod installiert. Aber das ganze ist immer noch alles andere als fertig.
HasteBin without limit: Xems' Hastebin

HummelLP

User / Kunde

  • "HummelLP" is male

Posts: 200

Location: Frankfurt

Thanks: 1

  • Send private message

11

Wednesday, February 6th 2013, 8:28pm

Ich habe grade versucht es auf meinen Nitrado server zu installieren habe es erst hochgeladen dann server gestoppt und dann die datei craftbukkit.jar gelöscht und denn spoutserver in craftbukkit.jar umbennant aber wenn ich ihn starte passiert nix =?

XemsDoom

User / Kunde

  • "XemsDoom" is male
  • "XemsDoom" started this thread

Posts: 758

Location: Zurich

Occupation: Sidekick

  • Send private message

12

Wednesday, February 6th 2013, 8:47pm

Ich habe grade versucht es auf meinen Nitrado server zu installieren habe es erst hochgeladen dann server gestoppt und dann die datei craftbukkit.jar gelöscht und denn spoutserver in craftbukkit.jar umbennant aber wenn ich ihn starte passiert nix =?
Du denkst aber nicht wirklich das Nitrado so dumm ist und wirklich alle JARs ausführen wird die craftbukkit.jar heissen, haha.
HasteBin without limit: Xems' Hastebin

Maddin1436

User / Kunde

  • "Maddin1436" is male

Posts: 2,589

Location: Dresden

Occupation: Software- and System Design Engineer

Thanks: 7

  • Send private message

13

Wednesday, February 6th 2013, 9:07pm

Kannste glaube nur auf nem root starten (Zumindestens läufts auf meinem root^^)

Bitte besucht unser neues Forum unter https://forum.nitrado.net| Please visit our new Forum at https://forum.nitrado.net